I am trying to create a bundle in Symfony 6.0.20. When adding that bundle in www\Acme\config\bundle.php it's showing the following error.
#message: """ Attempted to load class "AcmeTestBundle" from namespace "Acme\TestBundle".\n Did you forget a "use" statement for another namespace? """
Bundle file www\Acme\src\TestBundle\AcmeTestBundle.php
<?php
//symfony composer dump-autoload
namespace Acme\TestBundle;
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
class AcmeTestBundle extends AbstractBundle
{
}
www\Acme\config\bundle.php
<?php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Acme\TestBundle\AcmeTestBundle::class => ['all' => true],
];
coposer.js
"autoload": {
"psr-4": {
"App\\": "src/",
"Acme\\TestBundle\\": "src/TestBundle/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/",
"Acme\\TestBundle\\Tests\\": "tests/"
}
},
I think you could try to remove App namespace from both side as you try to register two different namespace where first could handle other the one.
Your class namespace still be:
If you need two different namespace in src folder, you should create two folders in your
src/
folder (ex:src/App
andsrc/Acme
):Your class namespace still be: