|
Symfony PHP Framework: part 2Posted: Nov 26, 2008In a previous article I spoke about my first impressions of the Symfony PHP framework. This article follows up with my thoughts after having used Symfony for a few weeks. When I first started working with Symfony I noticed I wasn't doing a lot of programming. Rather, I was editing configuration files and using the Symfony command line tool to auto-generate modules. This might seem like a dream to some developers, but I like programming so I was disappointed. Fortunately, once you start having to customize your project to a greater degree, you do still need to do a fair amount of programming, depending largely on the nature of the project. Now that I'm used to Symfony, I'm enjoying the programming even more as everything is very structured and logical. One nice feature (that is really a feature of PHP 5), is class autoloading. This means that classes that I place in specific places can be instantiated or called statically without me needing to include or require them from another source file. So, for instance, I have a class "UrlHelper.php" in the lib/util folder, and this is available from every other part of the application, including the templates. One of the most impressive features of Symfony is its ability to generate backend modules using the admin generator. As an example of what this is, imagine you have a table in the database, "car", where you store a different model of car per record. Using Symfony's command line tool, you generate a module to list, create, edit & delete records from the car table. The admin generator does not actually create source code which you can modify (as it inherits from pre-existing classes in the framework), but you're not stuck with the default set up as the module is highly configurable. Also, you can override things like the default templates with your own. Symfony comes with features that make dealing with forms easier, once you learn a few rules. My favourite forms feature is the Search engine friendly URLs in a Symfony project can be achieved with the routing system. This again uses YAML configuration files and is surprisingly simple yet powerful. For example, it is easy to route a request for /articles/php5_released.html to the module A small drawback with Symfony, in my opinion, is how page titles are set (as in the value of the I plan on updating this article with some more info soon, so do come back! |