I’ve never been a fan of fully-fledged (“big“) frameworks like Symfony or CodeIgniter. (There, I said it!) .
I’d rather just start from somewhere comfortable where I know every class that’s in scope and I know nothing is present that I don’t absolutely need.
It seemed silly to me that the simplest web applications can be 80% framework code and 20% application-specific code (even if that’s not at all in terms of code coverage on average, just present code). Another reason was that I love to learn. I don’t feel like I’m learning when I’m just learning an API or the contents of some slightly pretentiously presented user manual for a framework. Writing a framework, however?…
~ My angle ~
Looking at the things my friends use the big frameworks for; I find it strange that most of the use is to do simple things like handling the flow of the application; things we used to do with a few lines like a switch or if…elseif…endif statement.
Two years ago or thereabouts, I noticed that each time I started work on something new in PHP, I’d start by copying a load of stuff over from my last project. I then noticed that I’d become what I hated, kind of. Still, more recently, I decided to neaten this collection of classes up, formalise it and write some documentation that is understandable by people other than myself.
My framework, I have named simply Transcend Framework (TF for short and in the code…) to fit in with the branding of the rest of the stuff I work on. What does it include? Not much. I don’t need much.
- MVC stuff - Model & Controller abstracts and Views implemented using a fast, simple template engine that is extensible through inheritance.
- Extends PHP’s autoloading mechanism – just makes everything a little neater and quicker to get started.
- A configuration & message handling mechanism to ease the debugging and testing of applications in development and the configuration of applications in production.
It’s on GitHub if you want to take a look at it, but I strongly suggest you have a bash at putting something together yourself. It’s a great learning experience if you are just getting in to PHP. You can get a handle on organising classes, writing good inline documentation, inheritance, interfaces and lots more. Frameworks generally push language features to the max; so it’s definitely a good way to polish your knowledge. Feel free to fork TF and have a play.
~ Cringey summary ~
So, the answer to my slug in the title of this post? Your own. I think everybody should have a toolkit of code they use a lot, keep it as a git repo, include it with submodules so it’s easy to roll out updates to all your uses of it.
Cue cringes.