[eluser]milkboy[/eluser]
Hi everybody,
am new to codeigniter and just am looking for some feedback on my solution to extend codeigniter (maybe it might even be of interest to somebody). Sorry for the length of the post, but I am trying to be clear about I am trying to do. Just to clarify this seems to work, I'm just wondering if there is a better way. Warning: ONLY BASIC TESTING HAS BEEN DONE.
Some background: I am currently rewriting a system we are using with multiple clients. The system was originally built as a bespoke solution for one client. Other companies approached us about it, each requiring some bespoke modifications. Currently that means changes to the code for each clients, which as you can imagine is a big pain (thank god for SVN). So what I need is:
1) To be able to overwrite/extend my basic application with the clients bespoke changes. Currently CI looks for files in application, then system. I need it to look in extention, then application, then system.
2) As I am currently not sure which core or application controllers/models/views/libraries/helpers/config I will need to extend, all of these should be extendable. Hooks/errors/language files are unlikely to require extending, so are ignored for the moment.
Approach: I realised some changes to the core were probably required, although the aim is to keep these to an absolute minimum. I considered putting my application directly into the systems folders, but I wasn't sure how then to deal with controllers/models/views. Plus I figured, as our system is pretty big, this would just lead to bigger problems in the future with loads of my files being mixed up with core files. Finally extentions to the core libraries I would want to make, might then have to be done directly in the core file.
So I had a look at how CI loads the various elements and found the following files needed changing. Feedback is welcome. If anybody can tell me how to do this without touching the core, I would love to hear.
root/index.php: requires path to extention folder and define a constants.
root/system/codeigniter/Common.php: load_class() has to be changed to also look in extention folder, if required.
root/system/codeigniter/CodeIgniter.php: changes to main controller call (line 150+) so the right path and name for the controller are specified.
root/system/application/config/config.php: new 'subsubclass_prefix' setting, plus code to read config file of same name in extention folder (which can be used in any config file)
root/system/application/libraries/MY_Router.php: amend _validate_request() and add some new set and fetch functions
root/system/application/libraries/MY_Loader.php: amend model(), helper(), _ci_load() & _ci_load_class
The amended and new files are in the attached zip.
Thanks for any comments