xautoload

Tags: 
xautoload

xautoload never had a database cache. But now it has, thanks to O(log n).

XAutoload 7.x-5.x now has full support for PSR-4 as in Drupal 8.
So, you can now organize your module class files in Drupal 7 like this:

class: "Drupal\$module_name\Foo\Bar"
file: "$path_to_module/src/Foo/Bar.php"

Enjoy!

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

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.

Tags: 
xautoload

xautoload never had a database cache. But now it has, thanks to O(log n).

XAutoload 7.x-5.x now has full support for PSR-4 as in Drupal 8.
So, you can now organize your module class files in Drupal 7 like this:

class: "Drupal\$module_name\Foo\Bar"
file: "$path_to_module/src/Foo/Bar.php"

Enjoy!

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

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.