Composer plugin: how to add a custom autoloader?

Viewed 105

I have a custom autoloader that does a lot of behind-the-stage magic handling of class loading (https://github.com/exteon/chaining-class-resolver).

I want to distribute modules that rely on this loader as composer packages, for which I've already written a custom composer install plugin.

Is there a way I can tap into composer's autoloading sequence i.e. on post-autoload-dump to append my autoloader?

I have an obvious solution in building another autoload.php script that require()s vendor/autoload.php and using that to bootstrap the application; however:

  • extending the composer autoloader seems more elegant
  • I was pondering whether there will be a future need that the said custom autoloaded modules expose some composer paraphernalia, like composer commands (https://getcomposer.org/doc/articles/plugins.md#command-provider). This would not work with the obvious solution as composer will not call upon the custom bootstrap to load the classes.

So, is there a more elegant way to tap into the composer autoloader itself? i.e. include a custom autoloader that would be loaded with vendor/autoload.php ?

0 Answers
Related