zend-loader icon indicating copy to clipboard operation
zend-loader copied to clipboard

Class Map Generator removed

Open rcapile opened this issue 8 years ago • 10 comments

You mention the Class Map Generator (bin/classmap_generator.php) on the docs but removed it when zend-loader got separated from zf2. Did you miss the file ou should I remove from docs?

rcapile avatar Jan 11 '17 12:01 rcapile

+1 I used the classmap_generator.php of zendframework/zendframework package (https://github.com/zendframework/zendframework/blob/release-2.5.3/bin/classmap_generator.php) but actually i'm including each package as separate package, so I do not have those files anymore.

How can I recover a classmap_generator.php file?

pensiero avatar Feb 17 '17 13:02 pensiero

Meanwhile I published this: https://github.com/pensiero/zend-generators

pensiero avatar Feb 17 '17 13:02 pensiero

A classmap generator shouldn't be needed at all if you just rely on composer's...

Ocramius avatar Feb 17 '17 13:02 Ocramius

Actually in my Module.php the getAutoloaderConfig() method use it:

public function getAutoloaderConfig()
    {
        if (getenv('ENV') == 'development') {
            return [
                'Zend\Loader\StandardAutoloader' => [
                    'namespaces' => [
                        __NAMESPACE__ => __DIR__ . '/../src/' . __NAMESPACE__,
                    ],
                ],
            ];
        } else {
            return [
                'Zend\Loader\ClassMapAutoloader' => [
                    __DIR__ . '/../config/autogenerated/autoload_classmap.config.php',
                ],
            ];
        }
    }

should I replace it with something else?

pensiero avatar Feb 17 '17 14:02 pensiero

PS: autoload_classmap.config.php is the file generated by the classmap_generator.php script

pensiero avatar Feb 17 '17 14:02 pensiero

@pensiero just move all that stuff in your composer.json "autoload" section, sit back and relax :-)

Ocramius avatar Feb 17 '17 14:02 Ocramius

Am I good this way?

  "autoload": {
    "psr-4": {
      "Uala\\": "module/Uala/src/",
    }
  },

pensiero avatar Feb 17 '17 14:02 pensiero

Correct. No more need for pesky manual classmaps.

Ocramius avatar Feb 17 '17 14:02 Ocramius

I wanted to provide a PR, updating the documentation. However, ClassMapAutoloader documentation suggests the usage of classmap_generator.php.

Is there a valid use case for ClassMapAutoloader, without the generator? How would a classmap be generated, if the generator is gone? Is it compatible with a classmap generated by Composer? But then why would one not use Composer?

It seems that ClassMapAutoloader can be removed as well. @Ocramius / @froschdesign can you confirm that?

arueckauer avatar Nov 06 '19 09:11 arueckauer

This repository has been closed and moved to laminas/laminas-loader; a new issue has been opened at https://github.com/laminas/laminas-loader/issues/1.

weierophinney avatar Dec 31 '19 21:12 weierophinney