Composer autoload-dev not working

The autoload_psr4.php file does not contain the namespace from the autoload-dev section, only from the autoload section.

When my composer .json reads

"autoload": { "psr-4": { "Namespace\\": "src/" } }, "autoload-dev": { "prs-4": { "Namespace\\Tests\\": "tests/" } } 

And I launched

 composer require vendor/namespace 1.0-dev 

The file My / vendor / composer / autoload_prs4.php is displayed as

 // autoload_psr4.php @generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( 'Namespace\\' => array($baseDir . '/src'), ); 

Thanks!

+1
source share
1 answer

I assume that you are showing composer.json of vendor/namespace package. If this is the case:

See the docs . It says: "autoload-dev ( root only )". root means that it applies only to the root package. When you included the package, the composer.json file shown is not the root package, so the autoload-dev section is ignored.

+2
source

Source: https://habr.com/ru/post/1260826/


All Articles