Need Some MVC in Your Life?

March 4, 2008

Ok, so I got turned onto this blog entry on Ian Christian’s blog. If you read it, it references a phpguru entry that got my attention as it has thoughts on MVC by Rasmus Lerdorf

I don’t want to get caught-up in the rant so much but to take a chance to point out a little know MVC implementation. I’ve never called it a framework, it’s just an implementation of the MVC pattern aptly called MVCnPHP. Do you really need another MVC implementation, though? Of course not but I should point out that MVCnPHP has been around much longer than other MVC implementations…only Phrame – a Struts-ish implementation of MVC – is older. Why is that important? It’s been around a long time, has been in heavy use on production sites and avoids some of the issues noted in the above articles. Here’s a quick rundown of features:

  • 100% configureless. My XML configuration files. Just drop your views or commands into a directory and the controller does the rest.
  • Can be used with any template engine. We use Flexy, you can use Smarty or just raw PHP…your MVC implementation shouldn’t hand-cuff you to any other design decisions
  • It’s APC-friendly. While it is 100% configureless, the controller builds it’s configuration on the fly and will try to either write it to a file OR, if possible, store it in memory for even faster access.
  • As Rasmus said, avoiding the use of require_once and include_once helps. This package doesn’t do that because it is meant to run as a PEAR package (in fact that download above can be installed using the PEAR command line). If you want faster performance all you have to do is create the following function:
    function getOption($optionName = '')
    {
        global $conf;
        return $conf[$optionName];
    }
    

    Then in the files in this package replace stuff like:

    require_once 'Geeklog/MVCnPHP/CommandInterface.php';

    with

    require getOption('path_pear') . 'Geeklog/MVCnPHP/CommandInterface.php';

The goals when we built this were simple, to provide an easy to use, configureless MVC implementation that could be used as part of a true framework or be used stand-alone. If enough of you in PHP-land show an interest in this implementation I’d be happy to show some additional code showing this implementation in action…all you have to do is ask. Oh, and we did use PHPDocumenter for API documentation feel free to pump it through. I will try to publish it myself sometime soon.

Leave a Reply

Your email address will not be published. Required fields are marked *

*