Welcome Guest, Not a member yet? Register   Sign In
Cascades for everyone! - CodeIgniter ReLoaded
#1

[eluser]m4rw3r[/eluser]
I'm currently making a replacement Loader to CI, which will provide a true cascading filesystem.

I'm aiming to make it easier and more decoupled with the CI object, while retaining backwards compatibility (also trying to make general improvements to the loader).

Working cascades:

* Controllers
(with a slightly modified CodeIgniter.php file)
* Models
* Libraries
(Not the core libraries: config, input, benchmark, uri, output, lang, router or loader.
This because of the load_class() function, so they can only cascade over BASEPATH and APPPATH - default CI behaviour)
* Views
* Helpers
* Plugins
* Route config files
* Library config files
(extending config files with MY_ prefix)

Assembla svn page

Ideas, comments and suggestions are welcome!

PS. I do think it i PHP 4 compatible if I remove the chaining I've made in some places.
#2

[eluser]xwero[/eluser]
Extending config files doesn't need to be difficult. Just load more application specific config files later than system files.
#3

[eluser]m4rw3r[/eluser]
No it isn't, and the whole improvement wasn't so hard to do.

But the only thing preventing from a cascading of (nearly) everything is to remake the load_class() and get_config() functions.
#4

[eluser]m4rw3r[/eluser]
One thing that is annoying, is that CI allows libraries with the first char Capitalized.
It results in twice the number of calls to file_exists().

I know that it would be hard to change that now, but from a performance perspective, it would be better having all filenames lowercase.
#5

[eluser]louis w[/eluser]
Could you please explain what you mean by a true cascading file system? What does this do exactly?
#6

[eluser]m4rw3r[/eluser]
You can have multiple "modules" like Kohana's cascading filesystem, and everything except for the APPPATH.config/config.php and codeigniter/* cascades (in the next version, which I'm experimenting with, currently it cannot cascade the libs mentioned above).

So it cascades like this image describes it: http://upload.wikimedia.org/wikipedia/en...odules.png
#7

[eluser]louis w[/eluser]
Ahh ha. I like this idea, very interesting.
#8

[eluser]m4rw3r[/eluser]
EDIT: A later version is available in a later post in this thread.

Here is a diff file compared to the latest CI SVN.

It enables cascades for everything except for APPPATH.config/config.php and codeigniter/* .

Also, the database and scaffolding are loaded by the Loader class, and I've not implemented cascading for those yet.

The performance is really good, it is very much comparable with the default CI.

I have made some conventions to the filenames;
Library files have the first letter Capitalized
All other files are lowercase

This makes it a lot faster (otherwise it would have been about 10% slower)

A thing which isn't in the patch, is that you have to rename system/libraries/URI.php to Uri.php (I have windows, so I cannot move the file with SVN and then make a proper diff).

Usage:
After you've applied the patch, open up application/config/config.php.
The load_paths setting is the setting controlling the cascades, and that array defines what paths to use when searching for files.
#9

[eluser]dexcell[/eluser]
^
Thank you Martins.
I really like the kohana cascading system.
#10

[eluser]m4rw3r[/eluser]
Here is an update, the older one had some flaws.
Here are the features (repeating some):

Cascades for the following:

* Controllers
* Models
* Libraries
* Helpers
* Plugins
* Views
* Config files
* Lang files
* Routes
* Constants

These does not cascade:

* APPATH.config/config.php
* BASEPATH.codeigniter/*
* Database related stuff
* Hooks (coming soon)

Allows unlimited subdirs for the following:

* Controllers
* Models
* Libraries
* Helpers
* Plugins
* Views
* Config files
* Lang files

Extra features:

* possibility to load class files with Loader::class_file()
* possibility to use $name when loading models with an array in Loader::model() (key => $name)

Fixed errors since earlier patch (v 1):

* Loader::Library() when sent an array it generated a fatal error
* load_class() could not load libs in subfolders
* load_class() had errors with config files, variable naming error
* load_class() does no longer return the class instance if it is asked to not instantiate (provided an instance exists)
* Loader::model() could not load models in subfolders

This patch is relative to the system folder in SVN (unpatched, so revert before applying).
You still need to rename libraries/URI.php -> Uri.php




Theme © iAndrew 2016 - Forum software by © MyBB