Ibexa DXP Discussions

Community discussion forum for developers working with Ibexa DXP

I just want to generate a bundle

I am just trying to generate a bundle with the dedicated command …
But, something goes wrong with the autoloaded.

root@my:/var/www/my/ezplatform # php app/console generate:bundle

Bundle name []: InitialImportBundle
Target Directory [src/]:

Generating a sample bundle skeleton into app/…/src/InitialImportBundle
created ./app/…/src/InitialImportBundle/
created ./app/…/src/InitialImportBundle/InitialImportBundle.php
created ./app/…/src/InitialImportBundle/Controller/
created ./app/…/src/InitialImportBundle/Controller/DefaultController.php
updated ./app/…/tests/InitialImportBundle/Controller/DefaultControllerTest.php
created ./app/…/src/InitialImportBundle/Resources/views/Default/
created ./app/…/src/InitialImportBundle/Resources/views/Default/index.html.twig
created ./app/…/src/InitialImportBundle/Resources/config/
created ./app/…/src/InitialImportBundle/Resources/config/services.yml
created ./app/…/src/InitialImportBundle/Resources/config/routing.yml
Checking that the bundle is autoloaded
Enabling the bundle inside app/AppKernel.php
updated ./app/AppKernel.php
Importing the bundle’s routes from the app/config/routing.yml file
updated ./app/config/routing.yml
Importing the bundle’s services.yml from the app/config/config.yml file
updated ./app/config/config.yml

The command was not able to configure everything automatically.
You’ll need to make the following changes manually.

  • Edit the composer.json file and register the bundle
    namespace in the “autoload” section:

My composer.json look like that :

"autoload": {
    "psr-4": {
        "AppBundle\\": "src/AppBundle/"
    "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]

I modify it as well

"autoload": {
    "psr-4": {
        "AppBundle\\": "src/AppBundle/",
        "InitialImportBundle\\": "src/InitialImportBundle/"
    "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]

But that’s not enough.
rm -rf app/cache/* && php app/console cache:clear --env=dev

Do not run Composer as root/super user! See https://getcomposer.org/root for details
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class “InitialImportBundle” from namespace “InitialImportBundle”.
Did you forget a “use” statement for another namespace? in /var/www/my/ezplatform/app/AppKernel.php:50

I also tried with:

"autoload": {
    "psr-0": {
        "": "src/"
    "psr-4": {
        "": "src/"
    "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]

And with others vary. But nothing works.
What do I miss?


composer dump-autoload

Thanks dude !

I do not understand how the rest of the site could work without it.
Or why I no longer need to run it when I create new bundles.
But I put this in my list of commands to execute to solve these many problems that I do not understand …

There are some changes coming with symfony3. I will recommend when you start working with bundles , then add below code to your autoload to avoid any conflict. The composer dump-autoload will not be later required.

    "autoload": {
        "psr-4": {

Of course, you could add the bundle namespace and path to the autolaod before creating any bundle or creating the bundle and then execute the above command.

1 Like