简体   繁体   中英

Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "Use rBundle" from namespace "UserBundle\UserBundle"

php bin/console clear-cache:

PHP Fatal error: Uncaught Symfony\\Component\\Debug\\Exception\\ClassNotFoundException: Attempted to load class "Use rBundle" from namespace "UserBundle\\UserBundle". Did you forget a "use" statement for another namespace? in /var/www/html/projects/Event-Finance/api/app/AppKernel.php:21 Stack trace:#0 /var/www/html/projects/Event-Finance/api/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(48 8): AppKernel->registerBundles()#1 /var/www/html/projects/Event-Finance/api/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(13 2): Symfony\\Component\\HttpKernel\\Kernel->initializeBundles() #2 /var/www/html/projects/Event-Finance/api/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/App lication.php(64): Symfony\\Component\\HttpKernel\\Kernel->boot() #3 /var/www/html/projects/Event-Finance/api/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php( 148): Symfony\\Bundle\\FrameworkBundle\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Componen in /var/www/html/projects/Event-Finance/api/app/AppKernel.php on line 21

I have passed 2 days to fix this error by uploading, configuring symfony several time. Changing the directory permissions and so many thing. Finally I have fix this issues in my Symfony 3.4 project.

There are 2 things you need to do to fix this error:

  1. In the composer.json, modify the psr-4 section under autoload section like this.
"autoload": {
    "psr-4": {
        "": "src/"
    },
},
  1. Then execute the following command

composer dumpautoload

There is a typo in your bundle name:

Use rBundle should be UserBundle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM