Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Appkernel Symfony2中出现错误_Symfony - Fatal编程技术网

Appkernel Symfony2中出现错误

Appkernel Symfony2中出现错误,symfony,Symfony,我一直在犯同样的错误……我尝试过使用everyone解决方案,但运气不佳 错误:AppKernel.php第17行中的ClassNotFoundException: 试图从命名空间“AppBundle”加载类“AppBundle”。 您是否忘记了另一个命名空间的“use”语句? <?php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class

我一直在犯同样的错误……我尝试过使用everyone解决方案,但运气不佳 错误:AppKernel.php第17行中的ClassNotFoundException: 试图从命名空间“AppBundle”加载类“AppBundle”。 您是否忘记了另一个命名空间的“use”语句?

<?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 OC\PlatformBundle\OCPlatformBundle(),
        ];

        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();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
        }

        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');
    }
}

请检查您是否有目录
AppBundle
,如果它不存在,请从
AppKernel.ph
文件中删除此行:

new AppBundle\AppBundle(),

我认为您的AppBundle类没有(或定义得不好)。您应该在
src/AppBundle/AppBundle.php
中有这个:

<?php

namespace AppBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AppBundle extends Bundle
{
}

能否也与您共享AppBundle类?还有你周围的目录结构!非常感谢我的问题解决了:)很高兴知道,你能分享你的解决方案或选择下面正确的一个吗?这对帮助别人和解决这个问题很重要。感谢你,现在一切都好了。非常感谢:)如果我回答了你的问题,请接受答案:)