简体   繁体   English

symfony2 AppKernel查找内核类中的致命错误

[英]Fatal error in symfony2 AppKernel finding kernel class

I am using symfony2. 我正在使用symfony2。 The code in my AppKernel looks like as follows: 我的AppKernel中的代码如下所示:

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

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            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 Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new JMS\AopBundle\JMSAopBundle(),
            new JMS\DiExtraBundle\JMSDiExtraBundle($this),
            new JMS\SecurityExtraBundle\JMSSecurityExtraBundle()
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new My\BookBundle\MyBookBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
        }

        return $bundles;
    }

Now my code for one of the unit tests under Bookbundle looks like: 现在,我在Bookbundle下进行单元测试之一的代码如下:

namespace My\BookBundle\Tests\Controller;

use My\BookBundle\Services\TestHelper;
use My\BookBundle\Tests\BaseTest;

class WriterControllerTest extends BaseTest
{
    /**
     * @var TestHelper
     */
    protected $testHelper;

    public function __construct()
    {
        parent::__construct();
        $this->testHelper = $this->get('test_helper');
    }

    public function setUp()
    {
        $this->testHelper->setupTestData();
    }

Previously it was running the application and the test pretty smoothly. 以前,它运行应用程序和测试非常顺利。 Then I was adding lots of functionality codes (such as controller, repository function, etc.). 然后,我添加了很多功能代码(例如控制器,存储库功能等)。 Now when I was trying to backup the codes by writing tests I am having the following error in the command prompt: 现在,当我尝试通过编写测试来备份代码时,在命令提示符下出现以下错误:

PHP Fatal error: Class 'Symfony\Component\HttpKernel\Kernel' not found in /var/www/Symfony/app/AppKernel.php on line 7

Where the line 7 refers to the declaration of the AppKernel class as you can see in the above mentioned code. 如上述代码所示,第7行指的是AppKernel类的声明。

I am confused and I am unable to find the reason behind the sudden breaking in code. 我很困惑,我无法找到代码突然中断的原因。

Can you please help? 你能帮忙吗?

To @ONe: I have my autoload defined in app folder 要@ONe:我在app文件夹中定义了自动加载功能

To @Wouter J: Unit test is not using appkernel - it is only the error that is showing 致@Wouter J:单元测试未使用Appkernel-仅显示错误

To @Ramon Kleiss: I have the vendors installed and uninstalled and then reinstalled. 致@Ramon Kleiss:我已安装并卸载了供应商,然后重新安装。 Nothing changed. 没有改变。

I couldn't figured out what is the reason behind but I was able to solve the problem. 我不知道背后的原因是什么,但我能够解决问题。 It was related to permission change of the Test and Vendor folders. 这与“测试”和“供应商”文件夹的权限更改有关。 As I have mentioned that it was running earlier -- for some unknown reason permission for my bundles test folder and vendor folder was changed so it couldn't accessed proper files. 正如我提到的那样,它运行得较早-出于某种未知原因,我的捆绑软件测试文件夹和供应商文件夹的权限已更改,因此它无法访问正确的文件。 I removed my installation and took fresh clone from repository and installed the project as per rules and everything was fine. 我删除了安装,并从存储库中获取了新的克隆,并按照规则安装了项目,一切都很好。 I figured out the difference of the old and latest project filesystem and found that only permission was the difference. 我找出了旧项目文件系统和最新项目文件系统的区别,发现只有许可才是区别。

Thanks for answering though. 感谢您的回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM