2.09.2011

Fat-Free Framework for PHP


One thing I enjoy is when a technology just works. I personally find that most PHP frameworks try and extend themselves too far into complete solutions, trying to solve the problems few people have at the expense of complexity. This is why I have written my own frameworks over and over. Each time iterating over the model and trying to improve the performance and sensibility of the system. Even though I am pretty proud of my efforts, late last year I stumbled onto a framework that really caught my attention, the PHP Fat-Free Framework. It has the elements of simplicity I feel really allow a developer to push out code quickly. It's very well thought out and feels very tornado-like in it's design style. One problem I have always had with PHP frameworks were their lack of a good routing solution.

I like python, however, one issue I have with the general attitude of pythons core development is it's inability to accept that it too has flaws, even with some of it's core libraries. These are often dismissed when discussed as something you just need to work around and I find it hard to swallow the pill that just because it's more structured than PHP, the problems with the core (anyone who has used datetime and had to deal with timezones and mongodb cannot say there are no flaws in python) are not acknowledged well enough, or even documented well enough, to make coding as pleasant as I feel it could be. That being said, I did enjoy using twisted as a web framework. It had the simplicity in it's design I was looking for. It also is very powerful, and is probably the default framework I will go with for any python-based project I work on.

With all that in mind, I am a PHP developer, and I found Fat-Free to be a breath of fresh air. I finally feel I don't need to write a new framework and really have a place to begin all my future projects. Fat-Free PHP 5.3+, which is what I try to write everything in now. I like namespaces, even if the syntax is a little annoying, I understand the intention and the reasons we have to go with ye olde backspace. I also feel that web page rendering and routing fits very well with OOP and having a stronger OOP core in 5.3 is key.

Fat-Free, to me, feels very similar to tornado in it's framework design. You define your routing in the main file and it's all handled by included classes. The automatic importing of your classes is very easy to understand, and the routing is extremely simple yet powerful. The ORM tools provided are at least good enough to do anything you really need to, however, if it's not to your liking you just don't use it. I love that about F3. Nothing but the core is required. I like Smarty, especially V3, and I use it whenever I can. Even though the built-in templating supports a lot of the same features, I can do everything I need to do in Smarty, and I am more comfortable with extending it and it's syntax. As with the ORM libraries, you simply don't use f3 and you're off and running with whatever you want to use for rendering your pages.

So check it out. I would like to see your feedback and hear your feelings on the overall state of PHP frameworks.