Map-based autoloader across php and phar resources

⌈⌋ ⎇ branch:  Canonic Autoloader


include_once

Global autoloader

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 it once.

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

You may wish to override the automatic 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 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.