X Autoload Dev notes 2012 (partly deprecated)

A series of blog posts about the X Autoload Drupal module.

Most of the information here refers to older versions of the module and can be regarded as deprecated by the up-to-date xautoload documentation available on drupal.org.

For performance, the goal is:

  • As a minimum, to be competitive with existing solutions (currently looking at symfony and Composer)
  • To be 90% competitive with the theoretical optimum. This means, we may accept to be 10% slower than theoretically possible, if this can buy us architectural quality.

Optimize our loops

Both the Symfony UniversalClassLoader and the Composer ClassLoader have a minor performance flaw, if set up with too many namespaces:

For every direct lookup, they loop over the entire array of registered namespaces.

This is part of a series about
X Autoload

Virtualize the filesystem.

In symfony, a class finder implementation needs to do a file_exists() whenever it finds a candidate filepath. If that passes, it will return the candidate filepath. If not, it will try the same with the next candidate, and eventually return NULL.

This has two problems:

This is part of a series about
X Autoload

Subject: Separation of concerns, composition over inheritance.

Symfony's class loader

The existing autoload libraries found in symfony framework and reused in Drupal 8 core, basically consist of one object doing the entire job:

This is part of a series about
X Autoload

Currently the xautoload_ClassFinder_NamespaceOrPrefix does support these registration methods:

This is one part in a rather technical series about
X Autoload

PSR-0 and PEAR

Some time ago, the PHP framework interoperability group, consisting of people from different PHP frameworks, published a standard called PSR-0, with policies about how to namespace a class, and where to put the file the class lives in.

or: How to write a PHP autoloader.

This is a technical document, explaining implementation details for the X Autoload module on drupal.org.

Please apologize if the document may be incomplete. I simply do not have the time and energy to write this up all at once.


So, here is the wishlist for our specific autoloader: