创建Symfony 4项目时出现致命错误

时间:2018-03-13 22:44:03

标签: composer-php macos-high-sierra symfony4

运行后

     composer create-project symfony/website-skeleton my-project

我收到错误:

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  
!!  Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "FileResource" from namespace "App".
!!  Did you forget a "use" statement for "Symfony\Component\Config\Resource\FileResource"? in /Users/bastiennicolau/Documents/dev_web/my-project/src/Kernel.php:39
!!  Stack trace:
!!  #0 /Users/bastiennicolau/Documents/dev_web/my-project/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php(80): App\Kernel->configureContainer(Object(Symfony\Component\DependencyInjection\ContainerBuilder), Object(Symfony\Component\Config\Loader\DelegatingLoader))
!!  #1 [internal function]: App\Kernel->Symfony\Bundle\FrameworkBundle\Kernel\{closure}(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
!!  #2 /Users/bastiennicolau/Documents/dev_web/my-project/vendor/symfony/dependency-injection/Loader/ClosureLoader.php(38): call_user_func(Object(Closure), Object(Symfony\Component\DependencyInjection\ContainerBuilder))
!!  #3 /Users/bastiennicolau/Documents/dev_web/my-project/vendor/symfony/config/Loader/Deleg in /Users/bastiennicolau/Documents/dev_web/my-project/src/Kernel.php on line 39
!!  

我尝试过更改psr-4中的composer.json值,并在运行cache:clear之后仍然遇到相同的错误......

你会怎么做才能让它发挥作用?感谢。

1 个答案:

答案 0 :(得分:0)

您可以尝试通过打开src / Kernel.php来解决此问题,然后转到第39行。

删除“FileResource”然后再次开始输入。您的IDE(假设为PHPStorm)将建议您使用以下文件中的FileResource:Symfony \ Component \ Config \ Resource \ FileResource;

这应该自动添加到Kernel.php的顶部。

接受并运行composer update。这个问题应该得到解决。

最佳, 娜维斯