2

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

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.

Community
  • 1
  • 1
Vivien
  • 1,159
  • 2
  • 14
  • 34
  • Seems like your composer.json PSR-0 configuration is wrong, have you checked how other bundles does it? – Renato Mefi Feb 12 '16 at 11:11
  • @RenatoMendesFigueiredo thx, it was misconfiguration of PSR-0, I switched to PSR-4 as suggested by Jakub Zalas – Vivien Feb 12 '16 at 11:36

1 Answers1

3

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.

Jakub Zalas
  • 35,761
  • 9
  • 93
  • 125