问题描述
运行后
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
中的c $ c>值,并且在运行 cache:clear
后仍然出现相同的错误...
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.
推荐答案
您可以尝试通过打开src / Kernel.php来解决此问题,然后转到第39行。
You can try to fix this by opening src/Kernel.php and then go to line 39.
删除 FileResource,然后再次开始输入。您的IDE(假设PHPStorm)将建议您从以下位置使用FileResource:Symfony\组件\Config\Resource\FileResource;
Delete "FileResource" and then start typing it again. Your IDE (assuming PHPStorm) will suggest that you use FileResource from: Symfony\Component\Config\Resource\FileResource;
这应该自动添加到Kernel.php的顶部。
This should be automatically added in the top of Kernel.php.
接受并运行作曲家更新。该问题应得到解决。
Accept that and run composer update. The issue should be resolved.
最好,
Vess
Best,Vess
这篇关于创建Symfony 4项目时出现致命错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!