Welcome Guest, Not a member yet? Register   Sign In
Combine several extended classes and helpers into single file for easy distribution?
#1

[eluser]batfastad[/eluser]
Hi everyone

This might sound slightly "out there" at first. Basically I'm building a small back-end in CodeIgniter that I would like to easily be able to roll out to multiple projects in the future. At the moment it's a collection of controllers, helpers, extended core classes, views and an assets folder. If I want to keep this easy for me to redistribute then I'd like to try and keep the number of individual files down.

Views, controllers and models are obviously best to retain as separate files.
But I'm also extending quite a few of CI's core classes with my own: CI_Controller, CI_Form_validation and CI_Input. With possibly more to follow.

Is there a way I can combine these 3 into a single file?
Obviously not having them in the application/core directory will break the MY_ prefix autoloading. It would also be brilliant if I could store my custom helper functions in the same file as well. This allows me to preserve any application-specific core classes in application/core in the traditional MY_ prefix format, whilst being able to rollout updates to my core classes easily.

I'm currently using Phil's Improved Native Autoloader in config.php (see here... http://ellislab.com/forums/viewthread/218099/#1006583) to load my extended core classes without using the MY_ prefix so I can give them more recogniseable and logical names for easier redistribution.

This suggests to me that config.php is processed early enough in initiation that I might be able to just do a cheeky require('AdminCoreClasses.php').
As that's basically what Phil's native autoloader does but it looks at the current class name to specify which file to load. I would just be hard-coding a single file, which contains all my extended core classes in one go.

Is there a better way to do this?

Cheers, B


Messages In This Thread
Combine several extended classes and helpers into single file for easy distribution? - by El Forum - 10-14-2012, 04:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB