gpt4 book ai didi

php - fatal error : Class not found in AppKernel. PHP

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:52:02 28 4
gpt4 key购买 nike

我已经按照 Symfony 文档生成了一个新的 Bundle (ImgBundle),但是当在浏览器中重新加载应用程序时,它无法识别 bundle 的主类。

这是我的 ImgBundle.php:

<?php

namespace ImgBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class ImgBundle extends Bundle
{
}

应用内核.php:

<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
new ImgBundle\ImgBundle(),
];

if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();

if ('dev' === $this->getEnvironment()) {
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
}
}

return $bundles;
}

public function getRootDir()
{
return __DIR__;
}

public function getCacheDir()
{
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
}

public function getLogDir()
{
return dirname(__DIR__).'/var/logs';
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}

这里是错误:

1

提前致谢

最佳答案

你需要像这样用 psr-4 autoload 改变你的 composer.json:

"autoload": {
"psr-4": {
"": "src/"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
}

在您需要在控制台内启动之后:

composer dump-autoload

关于php - fatal error : Class not found in AppKernel. PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44990181/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com