我正在使用symfony2。在我AppKernel的代碼看起來如下:symfony2致命錯誤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;
}
現在我對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();
}
以前它運行的應用程序和測試相當順利。然後我添加了很多功能代碼(例如控制器,存儲庫功能等)。現在,當我試圖備份代碼寫我不必在命令提示符下鍵入以下錯誤測試:
PHP Fatal error: Class 'Symfony\Component\HttpKernel\Kernel' not found in /var/www/Symfony/app/AppKernel.php on line 7
凡7號線是指AppKernel類的聲明,你可以在上面所說的見碼。
我很困惑,我無法找到代碼中突然崩潰的原因。
你能幫忙嗎?
你在哪裏定義了自動加載?你在哪裏加載它? – fiunchinho
使用appkernel的單元測試...? –
你有沒有忘記安裝供應商? –