Composer autoload-dev does not work

£可爱£侵袭症+ 提交于 2019-12-12 10:55:43

问题


The file autoload_psr4.php not contains the namespace from "autoload-dev" section only from "autoload" section.

When my composer.json reads

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

And I run

composer require vendor/namespace 1.0-dev

My /vendor/composer/autoload_prs4.php file appears as

// autoload_psr4.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'Namespace\\' => array($baseDir . '/src'),
);

Thanks!


回答1:


My guess is that you're showing the composer.json of vendor/namespace package. If that's the case:

Take a look at the docs. It says: "autoload-dev (root only)". root only means it only applies to the root package. As you included the package, the shown composer.json file is not the root package and the autoload-dev section is thus ignored.



来源:https://stackoverflow.com/questions/36538972/composer-autoload-dev-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!