Search code examples
phpcomposer-phpautoloader

How to define custom autoloader in composer?


I am using Nette Framework which uses its own autoloader. How can I define custom autoloader or just exclude the standard one from composer so I can use my own?


Solution

  • Simply don't include it if you don't want to use it. Keep in mind you'll have to handle autoloading on your own.

    If your autoloader can work with it, you can use namespaces file generated by composer:

    Composer provides its own autoloader. If you don't want to use that one, you can just include vendor/composer/autoload_namespaces.php, which returns an associative array mapping namespaces to directories.

    Reference: Autoloading in the composer docs.