I know I haven’t written anything here for quite a while, but I just wanted to make a quick post about this totally amazing awesome MVC php framework called kohana. It was originally a fork of codeigniter (Another good php framework, albeit php4 grounded at the moment), although it’s come a long way since then.
It’s main feature (in my opinion) is it’s extensibility – You can override any file in the framework (bar some of the ones included by the bootstrap) simply by creating a file with the same name + the MY_ prefix in the application directory.
For example – Say I want to change the Controller class so that it initiates the session in the constructor (It might be better to initiate the session in a hook of some kind, but it serves as a decent example here).
The default controller class is stored in
system/libraries/Controller.php
To extend it I simply create the following file:
application/libraries/MY_Controller.php
And then I can simply create a class like so:
[sourcecode language="php"]
Class Controller extends Controller_Core
{
function __construct()
{
parent::__construct();
//Init Session
Session::instance();
}
}
[/sourcecode]
And the class is extended!
Best of all, because Kohana allows you to transparently extend files all of your controllers which extend Controller will automatically use your modifications as well as the system's version of Controller.
note – you can only really extend a library once. There are ways to get around this restriction, but it’s not really worth it.
You could also totally override the class by making a file called
application/libraries/Controller.php
In which you’d place
[sourcecode language="php"]
Class Controller_Core
{
function __construct()
{
parent::__construct();
//Init Session
Session::instance();
}
}
[/sourcecode]
If you do replace a core library, then make sure that you either remove all references to parts of the controller which are no longer available, or that you copy across the changes.
There are lots more tutorials available at http://learn.kohanaphp.com
Anyway, there’s much more cool stuff that kohana can do, so I’d deffinitely reccomend you give it a try
Alex
P.S. Did I mention it’s free?