X Autoload: Dev notes

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.

Goals

So, here is the wishlist for our specific autoloader:

  • Support for PSR-0, PSR-0-NG (*), PEAR, PEAR-NG (*), and arbitrary custom logic registered for a specific namespace or prefix.
  • Separation of concerns, composition over inheritance, slicing up our classes and objects into nice small components.
  • Unit tests: Keeping most of our components agnostic about the environment, esp. the filesystem, and any platform-specific global state.
  • Performance: Make direct lookups decently fast, and then put a cache layer on top of that.
  • Support older PHP versions: Support autoloading with namespaces, but do not require them for the autoloader itself.
  • A platform-agnostic library, that can be wired up with platform-specific logic.
  • As a minimum, be technically competitive to symfony's autoload system.

Further reading:

Add new comment