We've seen an explosion in development tools for the Internet in recent years. It seems like every developer has a better idea, and each implementation and language has its advocates on the best way to populate a web page.
In the world of the PHP developer, we've seen a flood of PHP Frameworks. If you Google the wiki on PHP Frameworks you'll see some 70 PHP Frameworks.
Why this proliferation of PHP frameworks, and why use a framework? Let me start with an example, I completed a web project last year where I used XHTML, CSS, PHP, MySQL, and jQuery, and that's it, the base tools, with out any frameworks or utility programs. This project was a complex, object-oriented, accounting and reporting application. It took about six months to complete version one. I found myself running into several problems during the process, where I thought there had to be a better way.
Here's what I wanted. A better way to ensure the site was secure from hacking. When your developing a site, security seems to be an afterthought to getting the application up and running. There should be a way to incorporate secure techniques automatically throughout the site.
I can't tell you what a pain loading required and interconnecting classes with their proper locations, and doing PHP includes and requires, on every web page was. A good part of my debugging time was taken up with making sure classes and data was visible when needed and in scope. Include_once gave me some debugging problems. My thought was there should be a better way to load classes and files through out the site, I did put in an autoloader, so I didn't have to list every class on a page, but it would have been nice if that was available out of the box.
Although I used an MVC layout for the site. During the course of development, some other folders and helper utilities were incorporated into the site, in what I want to say, was a non-standard way, and done more for expediency. It would be nice if a site structure was predefined that would account for the different type of utilities you'd need to complete a site. This would also speed all future development as I would know where things went right from the start.
Another area that took time was keeping track of session data and variables and when and where they were in scope, or no longer available, improved session and cookie handling would have been nice. Validating forms required helper utilities that were used on multiple pages of the site. The site was done in English, it would be nice, if I knew the site was easily transferable to any language.
I wrote my own MySQL classes and class managers for each of my database tables. Essentially, along with my own SQL queries for each table needed. This was a rudimentary Object Relational Model, that translated the SQL to PHP objects. It would have been nice if this ORM would be available up front and was richer with more functionality.
Thus we come to a definition of a framework. A framework is a packaged set of utilities along with a file structure, naming conventions, methods, and ways of working, to make web development more secure, easier, and help developers speed up the development of web applications. The idea is you drop in the framework at the start of the project, and use the same framework on every web application you develop. The result is an improved, more secure, site, and with much less time spent in development.
Sounds great, but there's a problem. It turns out that every developer who has coded a web site has a better idea on what a good framework should be, and how the code should work. Developers want to put together a framework that they want to use, and so they develop one, than decide that other developers would like their framework too, and put it out in the world. Thus we have some 70 PHP frameworks out there.
Thus the problems with frameworks. Until you standardize on a framework, you have to go through all the frameworks available to see which one is best suited for the way you want to and like to work. You find yourself constantly looking at frameworks, and the latest framework, to see if that model is better suited to your development, and has a better set of utilities, than your last framework. This is a major time suck. You need a method to quickly sort through the field and narrow the list. I'll talk about what you want and need to look out for in a framework in my next post.