2

我正在尝试创建我的第一个供应商捆绑包。我在这个问题中找到了很多信息,但我被卡住了。

在我通过命令安装的另一个项目中composer require vted/peary,文件在我的目录下正确可见vendors/vted/peary

但是当它尝试像这样在 AppKernel.php 中添加它时:

$bundles = array(
    ...
    new Vted\PearyBundle\VtedPearyBundle(),
    ...
);

我收到以下错误:

ClassNotFoundException in AppKernel.php line 24:
Attempted to load class "VtedPearyBundle" from namespace "Vted\PearyBundle".
Did you forget a "use" statement for "Vted\PearyBundle\VtedPearyBundle"?

我认为这可能是某个地方的命名问题,但我找不到。VtedPearyBundle.php类对我来说看起来不错。

4

1 回答 1

3

您当前的包结构更适合 psr-4 自动加载器:

{
    "autoload" : {
        "psr-4" : {
            "Vted\\PearyBundle\\" : ""
        }
    }
}

或者,您可以使用target-dirwith psr-0。但是,首选 psr-4 自动加载器。

于 2016-02-12T11:20:05.523 回答