Symfony: What is it good for?

Symfony Project HomepageSymfony is one of my favourite bits of technology. I've got plans to write several articles and tutorials on it, but as I know many people haven't yet heard of it, or are unaware of how it could help them, I thought it best to write an introductory article. So, here is an explanation of what Symfony is, why I use it, and why you may want to start using it too.

Symfony is a PHP framework. It is a large volume of extremely useful bits of code written in PHP and collected together under a common name, with lots of documentation and a set of additional tools to make web development easier, faster and safer! It aims to make the life of a developer much, much simpler.

What does Symfony do?

  • Drastically reduce the amount of code written
  • Vastly reduce development time
  • Improve the standard of coding in web apps
  • Not reinvent the wheel
Symfony contains a vast quantity of code needed to get any database-driven web application up and running, along with several tools to automate common tasks. A developer only has to specify the data model/structures which are needed for her application in a special format called YAML, then Symfony will build the database tables and create all the classes needed to access and retrieve the data as objects along with basic templates and forms for viewing and entering the data. Symfony also has an admin generator, meaning it is capable of building a complete administration system for the data. The amount of code written by the developer is minimised, and the development time is significantly reduced.

Symfony follows the Model-View-Controller (MVC) pattern and is completely Object Oriented. This means the code is organised, flexible, and extensible - if Symfony doesn't work the way you want it to, you always have the option to override the functionality. Developers are encouraged to follow the patterns and best practices used in Symfony in their own code, thus improving the overall standard of coding.

What Symfony doesn't do, is reinvent the wheel - it makes use of already proven tools where possible. For example Symfony supports either Propel or Doctrine as the ORM layer (for interacting with the database - I use Propel) and uses Phing for building projects. Functionality like search or sending mail is not included in the Symfony framework, instead there are plugins in the extensive plugin library and tutorials on how to include popular libraries from the Zend framework. This keeps Symfony lightweight and focused on what it does best, meanwhile developers have the flexibility to use their favourite tools rather than "what's in the box".

So what does the developer do?

Symfony does a great deal of the groundwork of setting up a web application, but it can only do so much. Because the code to create, edit, list and show the data is generated by Symfony from the data model, the resulting display and functionality is very generic. The developer then has the job of building templates, configuring forms, modifying data, and implementing advanced functionality.

The My First Symfony Project tutorial takes you through the basics of setting up a blog. After defining the data model for blog posts & comments and generating the CRUD code, the list view, which would effectively be the blog's index page, looks like this:
My First Symfony Project

Clearly, this looks nothing like a traditional blog. The ID and body don't need to be displayed, the title should link to the "single" view, there is no indication of how many comments each post has and the created at date needs to be formatted to be more human-friendly. There are also many features missing such as searching, RSS feeds, categories, tags and user profiles. The additional features, data formatting and the HTML + CSS templates all need to be implemented by the developer, so there is still plenty of work to do.

What is Symfony good at?

Symfony is excellent for building any website which features content management or web services. The ability to specify data models (or content types if you want to think of it that way) and get the basic CRUD functionality up and running quickly, means that small content management systems can be a breeze to build. In addition to this, Symfony follows a RESTful architecture and has a very extensive and flexible routing system for building URLs. This means creating pretty URLs is simple, and providing web services via specific URLs is also easy to do (think twitter feeds being provided at

The more I learn about Symfony, the more I love it. I'm using it to build all those little personal projects that I would otherwise never have time to complete due to the overhead of time required to get the simplest function (data handling, pretty URLs, user management) working from scratch. I also find that working with Symfony gives me a greater sense of satisfaction because I feel that the code I am producing is of a higher standard and much more reliable. I thoroughly recommend trying it out, even if you just run through the tutorials and pick up some good programming practices.

So what next?

Symfony does have quite a steep learning curve, and if you're planning to get started, there are a few things that you will need to be comfortable with first: You don't need to be an expert or even proficient in these things, but arming yourself with knowledge of these tools will not only ease your journey with Symfony, but will also improve your overall experience with programming, scripting and development tasks. I really recommend a little background reading!

Once you are ready to put your best foot forward and give Symfony a go, then the only way to get started is with a tutorial. Dive in with the My First Symfony Project tutorial, and then move on to the Jobeet job board tutorial, which is much more in depth and shows you how to put into practice some of the more advanced features. There is plenty of other material to help you get started, including the documentation & API, the forums, the blog, the outside blogs RSS feed, the google users group and of course, my snippet library!

I hope that this article has explained what Symfony is all about and also whet your appetite for learning it. If there is anything else you want to know, or feel could be added to improve this introduction, please drop me a line in the comments. Otherwise I wish you good luck on your journey with Symfony, let me know how you get on!