1

I want to install my own bundle so I did composer require "al37350/fftt-bundle": "*"

Then I activated the bundle in AppKernel.php

new Al\FFTTBundle\AlFFTTBundle(),

But when I did a php/bin console I have this error :

PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "AlFFTTBundle" from namespace "Al\FFTTBundle".
Did you forget a "use" statement for another namespace? in /var/www/yoloFFTT/app/AppKernel.php:19
Stack trace:
#0 /var/www/yoloFFTT/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(450): AppKernel->registerBundles()
#1 /var/www/yoloFFTT/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(116): Symfony\Component\HttpKernel\Kernel->initializeBundles()
#2 /var/www/yoloFFTT/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(137): Symfony\Component\HttpKernel\Kernel->boot()
#3 /var/www/yoloFFTT/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(124): Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands()
#4 /var/www/yoloFFTT/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(90): Symfony\Bundle\FrameworkBundle\Console\Application->add(Object(Symfony\Co in /var/www/yoloFFTT/app/AppKernel.php on line 19

File structure of bundle :

src
    Al
        FFTTBundle

and the namespace of AlFFTTBundle.php is Al\FFTTBundle;

When the bundle isn't in the vendor directory, it's work, any idea ?

2 Answers 2

1

Does the composer.json in your bundle contain psr-0 or psr-4 autoloading?

Example:

"autoload": {
    "psr-4": {
        "Al\\FFTTBundle\\": "src/AlFFTTBundle",
    }
}

For more info see: https://seld.be/notes/psr-4-autoloading-support-in-composer.

Sign up to request clarification or add additional context in comments.

1 Comment

I think one should mention that any supported composer autoloading mechanism would work (PSR-4, PSR-0, classmap and files).
0

After making this entry in composer.json

"autoload": {
    "psr-4": {
        "Al\\FFTTBundle\\": "src/AlFFTTBundle",
    }
}

run : composer dump-autoload

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.