Fatal error while creating Symfony 4 project

萝らか妹 提交于 2019-12-24 20:44:46

问题


after running

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

I get an error :

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
!!  

I've tried some things like changing the psr-4 value in composer.json, and still having the same error after running cache:clear...

What would you do to make it work ? Thanks.


回答1:


You can try to fix this by opening src/Kernel.php and then go to line 39.

Delete "FileResource" and then start typing it again. Your IDE (assuming PHPStorm) will suggest that you use FileResource from: Symfony\Component\Config\Resource\FileResource;

This should be automatically added in the top of Kernel.php.

Accept that and run composer update. The issue should be resolved.

Best, Vess



来源:https://stackoverflow.com/questions/49267045/fatal-error-while-creating-symfony-4-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!