0

Since the dynamic class loading with Zend\Loader\StandardAutoloader is very expensive, I generate a classmap and set it in the

Application\Module

public function getAutoloaderConfig()
{
    return [
        'Zend\Loader\ClassMapAutoloader' => [
            __DIR__ . '/../../data/cache' . '/' . 'autoload_classmap.application.php',
        ],
        'Zend\Loader\StandardAutoloader' => [
            'namespaces' => [
                __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                'MyNamespace' => __DIR__ . '/../../vendor/my/lib/src'
            ]
        ]
    ];
}

The file autoload_classmap.application.php contains a classmap for /module and /vendor/my/lib/src.

Is it enough to extend the getAutoloaderConfig() of only one module (e.g. Application) or do I need to do that in every the ClassMapAutoloader?

automatix
  • 14,018
  • 26
  • 105
  • 230
  • 1
    No, you can use composer and get rid of the ZF2 auto-loading. – AlexP Nov 15 '16 at 00:37
  • You mean just add (`php classmap_generator.php ... -a`) my classes to the `vendor/composer/autoload_classmap.php`? – automatix Nov 15 '16 at 11:19
  • `php composer.phar dumpautoload` check out the [autoloading documentation](https://getcomposer.org/doc/01-basic-usage.md#autoloading); it will require that you have the namespaces defined in a `composer.json` file. – AlexP Nov 15 '16 at 18:28

0 Answers0