创建 Symfony 4 项目时出现致命错误
Fatal error while creating Symfony 4 project
在运行
之后
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
!!
我尝试了一些方法,例如更改 composer.json
中的 psr-4
值,但在 运行 cache:clear
...[=15 之后仍然出现相同的错误=]
你会怎么做才能让它发挥作用?谢谢。
您可以尝试通过打开 src/Kernel.php 来解决此问题,然后转到第 39 行。
删除"FileResource",然后重新开始输入。您的 IDE(假设是 PHPStorm)将建议您使用 FileResource 来自:Symfony\Component\Config\Resource\FileResource;
这应该会自动添加到 Kernel.php 的顶部。
接受并 运行 作曲家更新。该问题应得到解决。
最好的,
维斯
在运行
之后 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
!!
我尝试了一些方法,例如更改 composer.json
中的 psr-4
值,但在 运行 cache:clear
...[=15 之后仍然出现相同的错误=]
你会怎么做才能让它发挥作用?谢谢。
您可以尝试通过打开 src/Kernel.php 来解决此问题,然后转到第 39 行。
删除"FileResource",然后重新开始输入。您的 IDE(假设是 PHPStorm)将建议您使用 FileResource 来自:Symfony\Component\Config\Resource\FileResource;
这应该会自动添加到 Kernel.php 的顶部。
接受并 运行 作曲家更新。该问题应得到解决。
最好的, 维斯