Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Many frameworks do have autoloaders, one that does not is <strong>CodeIgniter</strong> and you have to specify which classes you want to load all the time and which classes you want to load inside your controllers / models / views / libraries.</p> <p>It isn't completely necessary, but it is nice because it generally enforces a file structure and you also don't have to worry about remembering to include files at the top of your scripts.</p> <p><strong>[Edit]</strong></p> <p>Apparently clarification is needed on my <code>CodeIgniter</code> statement. Yes there is an <code>auto_load</code> place that lets you specify the libraries/modules that you want to load automatically at the start of every script, and yes there is a loader library, but they are not the same as a real autoloader.</p> <p>You have to specify which ones you want at the start, it doesn't know that you want to load the Pizza_Store modle until you use the custom </p> <pre><code>$this-&gt;load-&gt;model-&gt;('foo'); </code></pre> <p>which is equivalent to </p> <pre><code>include 'application/models/foo.php'; $this-&gt;Foo = new foo(); </code></pre> <p>But is not really the same as only having to call <code>$this-&gt;foo = new Models_Foo();</code> and CodeIgniter knowing what you mean by it, which is what happens when an autoloader is used.</p> <p><strong>[Edit part deux]</strong></p> <p>Nowehere in the code does it say <code>__autoload</code>, <code>spl_autoload</code> or <code>spl_autoload_register</code>. This is because it maintains PHP 4 compatibility. It is just the way that the framework has been built, there is a false autoload as I stated above, but it does this for each "autoloaded" class:</p> <pre><code>foreach($autoloaded_class as $type=&gt;$class){ if(is_application_class($class)){ include "application/{$type}/{$class}.php"; } elseif(is_core($class)){ include "core/{$type}/{$class}.php"; } } $array['Foo'] = new Foo(); $controller($array); </code></pre> <p>Which is essentially calling:</p> <p>include 'foo.php';</p> <p>at the top of every file no matter if you need it or not.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload