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 ?

al37350
  • 139
  • 2
  • 8

2 Answers2

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.

Freid001
  • 2,580
  • 3
  • 29
  • 60
  • I think one should mention that any supported composer autoloading mechanism would work (PSR-4, PSR-0, classmap and files). – lordrhodos Jul 02 '17 at 05:57
0

After making this entry in composer.json

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

run : composer dump-autoload

Rohit Batra
  • 674
  • 4
  • 18