Map-based autoloader across php and phar resources

⌈⌋ ⎇ branch:  Canonic Autoloader


Artifact [460029bb48]

Artifact 460029bb48958b613f6da02b16376a7c9555d60a:

Wiki page [include_once] by mario 2014-02-15 14:26:25.
D 2014-02-15T14:26:25.432
L include_once
N text/x-markdown
P e8c96d0e13732434dfe2a342cbcd18b3af422ffc
U mario
W 938
<h3>Global autoloader</h3>

If you are using the global autoloader for `/usr/share/php` then you can often just do:

    include_once("shared.phar");

Your include_path usually lists it already.

### Per-project autoloader

You can just copy the `shared.phar` from there and install it into a project directory, optionally rename it, then [update](wiki/update) it once. 

    include_once("./vendor/shared.phar");

You may wish to override the automatic [AUTOLOADER_UPDATE](wiki/AUTOLOADER_UPDATE) then for development setups.

### Project-wide

If you have a single application below your document root, then it might be even more convenient to utilize [`auto_prepend_file`](http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file) via `.htaccess`.

    SetEnv AUTOLOADER_UPDATE 1
    php_value auto_prepend_file /www/docroot/vendor/shared.phar

Which avoids even the `include_once` for the autoloader.


Z ea526d7a04b171685518791c934a52a8