Symfony 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:

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 http://twitter.com/username).
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:
- The Model-View-Controller (MVC) pattern
- Object Oriented Programming principles (objects, data abstraction, inheritance etc)
- Basic PHP, SQL and database management knowledge
- Development environment setup & management (virtual hosts, symlinks etc)
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!


12th Jun
Remiz says:
Nice presentation. I think the beginning with symfony is not really easy but after you get so much things done that it’s hard to go back the old way. Just thinking that there is still people coding php apps from scratch make me sad :(
12th Jun
ErisDS says:
Thanks for taking the time to write here :)
There is definitely a steep learning curve with Symfony, but as you say once you get past that it is well worth the work you have put in. It makes development and testing SO much easier & the thought of writing from scratch after using Symfony is like the thought of riding a horse everywhere once you’ve driven a car!!
17th Jun
Xavier Luthi says:
Thanks for this good introduction post about Symfony.
It explains well the strong points of Symfony and why you’re using it. But did you already face a situation where Symfony was not a good solution? This feedback is also very interesting to better understand the possibilities (and limitation) of the framework ;-)
20th Jun
Zoja says:
A good article about Symfony :) Good to see another fan of my favourite framework :)
21st Jun
Dennis Gearon says:
Yes, the learning curve is pretty intense. Logically, I understand the basic premise, but there are so many layers involving routing, forms, validation, and other aspects, one could build something with it and barely touch its power. (Maybe some of the power isn’t needed ;-) I can’t seem to get past day 10 of jobeet. There are sometimes when they don’t give specific enough directions on modifying files and one mistake can make the whole project not work. Sooooooo, I”m going to start over, again, and load their predone versions of the tutorial and see if they work and compare them to what I am doing. ONE THING – ‘postion’ is a reserved keyword in my favorite database engine – PostgreSQL. I tried to change the tutorial to use ‘job_position’, but the scaffold generation changes this different ways in different places and makes it hard to chase down the required edits, (JobPosition, job_position, jobPosition, etc.) So I’m going to bite the bullet and install MySQL for the demo. It’s too bad they made the demo on the old LAMP standby. I feel MySQL’s days are on the way out for free, QUALITY, ROBUST, applications. PostgreSQL was always more robust and has caught it everywhere else since about 3 years ago. I’m looking forward to getting a handle on Symfony, that’s for sure. I may later switch to Zend Framework – it seems to have more open source development structure in its community and is getting more hits on all the development websites.
21st Jun
ErisDS says:
@Xavier Luthi Your question is a very good one. I will respond again later with an in depth answer.
@Zoja Thanks for your comment, I am always pleased to meet other Symfony fans :)
@Dennis Gearon Oh yes, sooo many layers. So much stuff I haven’t touched yet. I’ve really gotten to grips with Forms & Validation, but I’m still working on routing and other aspects.
Regarding the use of the word “Position” does it really still cause problems when it is together with another word like “JobPosition”? I use MySQL so wouldn’t know. If it is the case you can’t really change it to “job_position” because the naming convention in Symfony for models is Camelized so yes you will run into problems. Try changing it to “JobRole” everywhere you find “JobPosition” and it should all work the same.
Regarding having problems with the forms at days 10/11. I would be very interested to hear more about that to see if I can’t clarify some of where they go wrong. I am planning to write my own tutorial, specifically focusing on the forms as I feel the Symfony docs don’t go deep enough. If you get in touch via Twitter DM or my Contact form perhaps we can talk more about this?
To everyone else reading this, I’d love to hear about any problems you’ve had with Symfony, the docs or the Jobeet tutorial :)
21st Jun
Dennis Gearon says:
I will get back to you on this by the end of monday. I realize this is an Interent Eternity, but busy with habitat for humanity.
21st Jun
Dennis Gearon says:
Early end to Habitat assignment. The problem that I had was that there seemed to be something wrong with the routing as I interpreted the directions. When I changed the routing file for the ‘token’, and then drilled down through the design to edit any individual job listing, I got an error for bad routing related to no route for ‘id’ based display. Sooo, I’m going to start over again, but keep comparing my results to the svn repository. Yes, I did make the mistake of putting and underscore ‘_’ seperated prefix to ‘position’. If I do this again with postgresql, I will just change it to ‘jposition’ (as ‘Java’ as that sounds :-).
21st Jun
ErisDS says:
I’d be interested to see your file. The Symfony documentation is not particularly well explained it is true.
Also I meant to add in reply to this:
“I may later switch to Zend Framework – it seems to have more open source development structure in its community and is getting more hits on all the development websites.”
Zend has some really nice bits: Lucene Search, the Mail component. Symfony makes use of these components instead of reinventing the wheel and doing it’s own bits and instead concentrates on making it as easy as possible to get your application of the ground. Granted it’s really not all that simple at the moment and requires a LOT of learning, but once you get the basics of forms & routing under your belt you’re armed and good to go on any project.
22nd Jun
Rizwan says:
Hi,
Can you enlist how Symfony is better than Cake which gives the same functionality
27th Jun
Dennis Gearon says:
ErisD, how about I send you the whole project? Then you could take a look at it for me?
28th Jun
ErisDS says:
Of course? Please contact me via Twitter DM or my contact form with your email address & I will get in touch :)
31st Oct
Peng says:
Great site and great photos. Very impressed with the geekery and beauty.