Welcome Guest, Not a member yet? Register   Sign In
Is CI's Autoload Mechanism Good Enough?
#1

[eluser]WoOzY KinG[/eluser]
Hey every CI lover (like me),

I just read this blog post at CodeFeast: http://codefeast.com/?p=11.
The article points out some important things about autoloading and its performance.

So I started to wonder how does CI implement its autoload functionality and is it good enough?

Any CI guru could explain a bit? Thanks in advance Big Grin
#2

[eluser]Rick Jolly[/eluser]
CI's auto-loading is different from php 5 autoloading. With CI auto-loading you can globally initialize selected libraries, helpers, and plugins. With php 5 autoloading, you can include any class on demand as it is instantiated (no need for require/include or CI's loader class). Autoloading implementation is up to the developer.
#3

[eluser]WoOzY KinG[/eluser]
[quote author="Rick Jolly" date="1217458003"]CI's auto-loading is different from php 5 autoloading. With CI auto-loading you can globally initialize selected libraries, helpers, and plugins. With php 5 autoloading, you can include any class on demand as it is instantiated (no need for require/include or CI's loader class). Autoloading implementation is up to the developer.[/quote]

Sure, that's exactly what I'm wondering how CI's autoloading mechanism's done, since it has to be compatible with PHP 4.
#4

[eluser]xwero[/eluser]
CI's autoloading is based on a few predetermined locations namely the directories libraries, models, views, helpers, language and plugins in the application and system directories. There is a filecheck based on the first parameter of the loading method but because it searches in a specific directory the check overhead is pretty small.

If you want to see how it works you can check the loader library.
#5

[eluser]WoOzY KinG[/eluser]
@xwero: thank you, I've already checked the lib and got the basic idea. Thanks again for the explanation.




Theme © iAndrew 2016 - Forum software by © MyBB