Map-based autoloader across php and phar resources

⌈⌋ ⎇ branch:  Canonic Autoloader


Update of "include_once"

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: 460029bb48958b613f6da02b16376a7c9555d60a
Page Name:include_once
Date: 2014-02-15 14:26:25
Original User: mario
Mimetype:text/x-markdown
Parent: e8c96d0e13732434dfe2a342cbcd18b3af422ffc (diff)
Content

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.