Rasmus's no-framework PHP MVC framework
I am obviously not a fan of such frameworks. I like stuff I can understand in an instant. Both because it lets me be productive right away and because 6 months from now when I come back to fix something, again I will only need an instant to figure out what is going on. So, here is my current approach to building rich web applications. The main pieces are:
I don't have much of a problem with MVC itself. It's the framework baggage that usually comes along with it that I avoid. Even parts of frameworks can be useful as long as you can separate the parts out that you need. As for MVC, if you use it carefully, it can be useful in a web application. Just make sure you avoid the temptation of creating a single monolithic controller. A web application by its very nature is a series of small discrete requests. If you send all of your requests through a single controller on a single machine you have just defeated this very important architecture. Discreteness gives you scalability and modularity. You can break large problems up into a series of very small and modular solutions and you can deploy these across as many servers as you like. You need to tie them together to some extent most likely through some backend datastore, but keep them as separate as possible. This means you want your views and controllers very close to each other and you want to keep your controllers as small as possible.
Goals for this approach
- Clean and simple design
- HTML should look like HTML
- Keep the PHP code in the views extremely simple: function calls, simple loops and variable substitutions should be all you need
- Input validation using pecl/filter as a data firewall
- When possible, avoid layers and other complexities to make code easier to audit
- Avoid include_once and require_once
- Use APC and apc_store/apc_fetch for caching data that rarely changes
- Stay with procedural style unless something is truly an object
- Avoid locks at all costs
Be sure to read it as he explains how to rethink using the "all powerful" frameworks outthere, which makes things much more difficult to quickly get something out the door. I've been thinking about looking at using MVC but it may be best to stick away from trying for the moment and maybe attempt to try MVC with a new language like Ruby on Rails.