问题描述:

I'm trying to create my first vendor bundle. I have found a lot of informations in this question but i'm stuck.

  • My github repository is available here :

    https://github.com/vtedesco/Peary

  • I have registered it in composer :

    https://packagist.org/packages/vted/peary

In another project I have installed it via the command composer require vted/peary, files are correctly visible under my directory vendors/vted/peary.

But when it try to add it in AppKernel.php like this:

$bundles = array(

...

new Vted\PearyBundle\VtedPearyBundle(),

...

);

I get the following error :

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"?

I think it's maybe a naming issue somewhere but I can't find it. The VtedPearyBundle.php class look good for me.

网友答案:

Your current bundle structure is more suitable for the psr-4 autoloader:

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

Alternatively, you can use the target-dir with psr-0. However, the psr-4 autoloader is preferred.

相关阅读:
Top