So I made this MVC-framework in 27 lines of code…

It started as a generic include-script for the redesign of my commercial homepage, Pedersen Mediaconsult and suddenly I got an epiphany. ;)

Introducing… The OneFileFramework, a complete (well, sort of) web framework in PHP that consists of ONE single file (index.php) consisting of 27 actual code lines. :D

The webpage I set up for it (and the demo) pretty much explains it all (form validation, MVC-orientation and so on). I haven’t set up any way of providing feedback for it yet, though. So I’d like comments to be posted to this blog entry.

I’d especially like to hear if anyone can find a way to fool OFF into security attacks using the $p parameter.

  • Alec

    Nice framework! I found it through your reply when I was reading this:

    It’s interesting to see that so many people are fanatical about the bigger frameworks like Zend or CodeIgniter, while I’d bet that most of those people only use a fraction of the framework’s possibilities and have no clue what it’s actually doing. And when it comes down to it, all you need for a basic MVC setup is something like your OFF framework and expand it with just the things you really need.

  • I don’t even have to look at the code to know you’re on to something. I have worked with a popular PHP framework and was disgusted — quit the job. Majority of devs out there seem to think a framework represents some form of systems architecture. And yeah, they don’t know what it’s doing — the most inefficient db access I’ve ever seen. Do people really think they can “generate” an application from a database schema? The problem is they don’t know what they don’t know. We have a lost generation who never learned fundamentals and the huge value of using what’s already in the language to assemble a solution appropriate to their business domain.

  • dss

    Just a little thing I noticed was at the bottom of the index.php file you have
    if (!is_file(“views/$p.php”))
    $p = $cfg_error404;

    but $p isn’t used after that so that call goes nowhere. I’m guessing that should be put up before the controller check.