Map-based autoloader across php and phar resources

⌈⌋ branch:  Canonic Autoloader


Canonic_Classmap implements the php script traversal, tokenization and map building process.

Usually it's run via the static ::update() method. If run from the default Canonic_Autoloader mechanism, it just cares about the directory tree it resides in.

It can however map multiple source repositories. For instance:

    array(__DIR__, "/usr/share/php")

Will read in the surrounding tree, but also the global path. An identifier map of both will be stored within the phar.

It's important to understand that only file references from the first directory will be converted into relative paths. The /usr/share/php/* filenames will stay absolute.

If such a manual updating procedure is in place, automatic updating via shared.phar itself shouldn't be utilized further. It would still just default to handling only the directory tree it's contained in.

More specific

You can also forgo the static ::update approach, and handle the details yourself:

$cm = new Canonic_Classmap;

And read in directories yourself:


None of the mapped paths will be relative then.

You then have to write the results somewhere yourself in a format that shared.phar or its stub can use:


Or update it also within the phar://