A Simple Framework

April 16, 2011 at 16:32 (Development, PHP) ()

For many reasons I’ve been wanting to develop something new and from scratch for quite a while. Mainly because most of the coding I do seems to be tweaking existing code or copying and pasting existing structures. After reading a few different tutorials on building a MVC Framework I thought I could join every developer and their dog and have a go at building a framework of my own. It was intended as an educational exercise for myself and so I’ve kept things as simple as possible, especially for the first version. It’s not an MVC framework as I haven’t yet included any support for models. At this stage it’s Controller Action View but it is more or less working now. I still need to finish it off and then decide how practical it is to actually build something with.  Who knows, I may then even release it for scrutiny from others.

In true He-Man style here are a few things I’ve learnt (or rediscovered) in the process:

  • mod rewrites may well be working but just redirecting to the wrong place and producing page not found errors
  • setting <base href> won’t work in IE if you have invalid html before it (during debugging)
  • There’s no need to use DIRECTORY_SEPARATOR constant (I didn’t even know it existed) when building paths as a forward slash will work in Windows
  • You can use reflection to check the number of required arguments when dynamically calling functions


$method = new ReflectionMethod($controller,$action);
$requiredArgs = $method->getNumberOfRequiredParameters();


Permalink Leave a Comment