gpt4 book ai didi

php - Composer require-dev 在不同的包中需要依赖 require-dev

转载 作者:可可西里 更新时间:2023-11-01 13:19:03 27 4
gpt4 key购买 nike

我有一些命名空间的测试被自动加载到包 A 中使用

"autoload-dev": {
"psr-4": {
"Vendor\\PackageA\\PhpUnit\\": "tests/PhpUnit"
}
},

这很好用。

我有另一个包,包 B,它也有命名空间测试,需要包 A 中的命名空间测试之一

"autoload-dev": {
"psr-4": {
"Vendor\\PackageB\\PhpUnit\\": "tests/PhpUnit"
}
},

但是,当我尝试将文件包含在包 B 中时,找不到该类

use Vendor\PackageA\PhpUnit\MyTestFromA;

class MyTestFromB extends MyTestFromA
{

让我觉得其他包中的 autoload-dev 东西没有被加载。

PHP Fatal error: Class 'Vendor\PackageA\PhpUnit\MyTestFromA' not found in /full/path/to/PackageBClass.php on line 3

当我尝试从包 B 中导入使用 autoload 而不是 autoload-dev 自动加载的文件时,我没有收到任何错误。

我该如何克服这个问题?

我的一部分想法是只为测试制作一个包,并在没有 autoload-dev 的情况下自动加载它,但我想先确认一下。

最佳答案

解决方案:Composer autoload-dev does not work .

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.

关于php - Composer require-dev 在不同的包中需要依赖 require-dev,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40977627/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com