Automap is a map-based PHP autoloader. As such, it is composed of two parts :
A builder program scans the PHP scripts composing your application, detects the symbols they define (classes, interfaces...), and registers them into a map file. Once it is done, the map file contains a list of every symbols defined in your scripts, and each symbol is associated with the file it is defined in. The map file is built only once (or when PHP scripts are modified and define a new class). It is built using the PHP interpreter in command line mode (text/shell/command mode).
The map file is an integral part of the software and is distributed with the program scripts and the automap runtime.
At run time, the application's main script first includes the Automap runtime (the automap.phk file) and, then, loads one or several map files. From this point on, any reference to a symbol present in one of the loaded maps will trigger the autoloader and automatically load the appropriate PHP scripts.
Note: We talk about symbols, and not classes because, even if PHP currently supports class autoloading only, it can be extended in the future to autoload functions and constants too.
Benefits : Compared to path-based autoloaders, Automap :
- is much faster,
- removes the constraints on file and directory naming,
- removes the limitation of one symbol per file,
- provides an optional PECL extension. When using this extension, Automap is by far the fastest PHP autoloader available today.