First impressions of Symfony PHP Framework

In the last few years, every project I’ve worked on has run on top of Zend Framework or a custom in-house framework. Most of my work involves extending existing applications and that’s the major reason I haven’t looked into any of the alternative PHP frameworks out there. In the last few months there have been tons of blog posts on the subject of PHP frameworks so I decided to do a little self-motivation exercise and learn a new one.

I checked out most of the popular PHP framework websites, read a little about each, browsed the community and tutorial pages and after a few hours came to the conclusion that I was going to have a crack at building a site using Symfony. The main reason I chose Symfony is that it takes a completely different approach to building a website from ZF. Using Zend Framework sometimes feels like driving a tank, it’s beauty is that it’s completely flexible but the downside of this is that there’s a lot of code to write before you get to where you want. Not interesting code either. You have to write your controller skeletons, your basic models, your CRUD functions, your views. You know, the stuff you’ve written a million times. If John Rambo taught us anything, it’s that sometimes you don’t need a tank, you need a small, fast boat to get in quick and get the job done. Zend’s strength lies in long term projects that require scalability and customisation. Symfony on the other hand specialises in code generation and speeding through the boring, repetative tasks associated with getting a web application up and running.

One of the things that drew me to Symfony is the documentation. They have free books that teach you every aspect of the framework and a 24 day tutorial called Jobeet that walks you through every step of application building in Symfony. I decided to build the Jobeet app and see how it worked for me.

The first thing you notice once the environment is set up is the lack of coding needed. Symfony provides a PHP command line interface and it’s simply a case of writing some YAML configs and running various ORM scripts (Propel and Doctrine are the default ORMs). By using the command line and some simple configs you can generate the models, the database structure, the controllers, the views, the CRUD functions and associated forms. Within a few hours of work I had a fully functioning basic site and I was pretty impressed with the way Symfony handles code generation.

Symfony also comes with two front controllers instead of one. One is for the actual web application and one is for the debug version. The debug version comes with full logging and analysis tools and it’s a really nice feature. I’m sure it’ll come in useful when making small edits in live environments or doing routine maintenance and performance upgrades.

As of writing this post, I’ve only had time to run through the first 6 chapters of the Jobeet project so I’ll be writing another post when I get a bit deeper into the workings of Symfony. That’s it for now but if you’re interested in learning more, head over to the Symfony website and have a run through some of their tutorials. Even if you’re not planning on using Symfony for production sites, it’s still a useful exercise to see how a ORM-based framework like this can cut down on the amount of boring coding you have to do.

This entry was posted in Open Source, PHP, Symfony, Zend Framework. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>