Pages: 1 2 3 4 5 6

Thanks to the rise of the PHP frameworks the Model View Controller pattern is becomming quite populair. To get a good idea how this works and what job PHP and Apache have, I’ve written a short example Hello World application which implements the MVC model without the use of a framework.

—-

I’m working on a PHP framework for a dutch IT company; Bean IT. This framework does not support the Model View Controller* pattern yet. I’ve got a DB abstraction layer which implements the model in the form of Active Record’s*, but there are no Controllers or Views. I like the MVC pattern, as well as the clear url’s which come with the routing solutions in most frameworks.

The solution I see most, is that Apache always rewrites a request to the same PHP file (single file entry point), after which a router object in the PHP script takes over and calls the action on the correct controller. This method is recommended in tutorials of codeignitor and zend framework (and probably also other frameworks).
The 2 mayor drawbacks of the ’single file entry point’ method are, that static loading is nearly impossible and lots of classes are loaded even for the simplest page request. Both of which are bad for performance. Read these 2 blog posts to understand why: “Remember: be nice to byte code caches” and “How fast is your framework”.
Let’s try to find a solution that does allow static loading.

Pages: 1 2 3 4 5 6