首页 > 解决方案 > PHP Symfony 试图从命名空间“Sonata\IntlBundle”加载类“SonataIntlBundle”

问题描述

我一般是 Symfony 和 PHP 的新手,我只想从 GitHub 建立一个项目,指令说我必须运行 composer update。所以在这个命令之后,一个错误日志:

 Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception

  [RuntimeException]                                                                                                                                                                                                               
  An error occurred when executing the "'cache:clear --no-warmup'" command:                                                                                                                                                        

  Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "SonataIntlBundle" from namespace "Sonata\IntlBundle".                                                                   
  Did you forget a "use" statement for another namespace? in /Users/xxx/Documents/project/app/AppKernel.php:28                                                                                                                 
  Stack trace:                                                                                                                                                                                                                     
  #0 /Users/xxx/Documents/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(427): AppKernel->registerBundles()                                                                                        
  #1 /Users/xxx/Documents/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(128): Symfony\Component\HttpKernel\Kernel->initializeBundles()                                                            
  #2 /Users/xxx/Documents/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(62): Symfony\Component\HttpKernel\Kernel->boot()                                                           
  #3 /Users/xxx/Documents/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(117): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Obj  
  ect(Symfony\Component\Console\Output\ConsoleOutput))                                                                                                                                                                             
  #4 /U in /Users/xxx/Documents/project/app/AppKernel.php on line 28                                                                                                                                                           

  PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "SonataIntlBundle" from namespace "Sonata\IntlBundle".                                                              
  Did you forget a "use" statement for another namespace? in /Users/xxx/Documents/project/app/AppKernel.php:28                                                                                                                 
  Stack trace:                                                                                                                                                                                                                     
  #0 /Users/xxx/Documents/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(427): AppKernel->registerBundles()                                                                                        
  #1 /Users/xxx/Documents/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(128): Symfony\Component\HttpKernel\Kernel->initializeBundles()                                                            
  #2 /Users/xxx/Documents/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(62): Symfony\Component\HttpKernel\Kernel->boot()                                                           
  #3 /Users/xxx/Documents/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(117): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Obj  
  ect(Symfony\Component\Console\Output\ConsoleOutput))                                                                                                                                                                             
  #4 /U in /Users/xxx/Documents/project/app/AppKernel.php on line 28       

谁能帮我解决这个问题?我有点迷路了。

标签: phpsymfony

解决方案


正如@Cid 提到的,我重新克隆了存储库,这次使用 composer install 而不是 update ,它工作得很好!


推荐阅读