I try to install a custom Symfony bundle in my application. I created the bundle with the following folder structure:
.
├── composer.json
├── composer.lock
└── src
└── Namespace
└── CoreBundle
├── Controller ...
├── CoreBundle.php
├── Entity ...
├── Helper ...
├── Repository ...
├── Resources ...
├── Services ...
└── Tests ...
I successfully installed the bundle by composer install in the vendor folder. There it is under vendor/namespace/core-bundle as a sym-link (I loaded it locally).
After that I added new Namespace\CoreBundle\CoreBundle(), in the AppKernel.php and this produces the following error:
(1/1) ClassNotFoundException
Attempted to load class "CoreBundle" from namespace "Namespace\CoreBundle".
Did you forget a "use" statement for another namespace?
in AppKernel.php (line 25)
I tried to copy the folder manually in vendor folder, if there is any problem with the sym-link, but it produces the same error. I checked out the autoloaded classes by dump(ClassMapGenerator::createMap('/path/to/symfony')); and I don't found my namespace there. Is my configuration wrong or my folder structure? If you need more code, I'll update my question as fast as possible.
Update: My bundles composer.json:
{
"name": "namespace/core-bundle",
"license": "proprietary",
"type": "symfony-bundle",
"autoload": {
"psr-4": {
"Namespace\\CoreBundle\\": "src/Namespace/CoreBundle"
}
},
"require": {
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"liip/imagine-bundle": "1.9.*",
"php": ">=5.5.9",
"symfony/symfony": "3.3.*"
},
"require-dev": {
},
"extra": {
"branch-alias": {
"dev-master": "development"
}
}
}
composer.json.composer.json."Namespace\\CoreBundle\\": "src/"in the autoload psr-4 part? Edit: nvm - was thinking psr-0. Does it work after you manually dump the autoloader usingcomposer dump-autoload -a?composer dump-autoload -adid the trick!