我如何修复symfony缓存生成的文件

时间:2016-06-30 20:47:48

标签: php symfony frameworks

我刚刚开始使用symfony2,我有一个巨大的障碍,我似乎无法弄明白。我创建了一个名为AppKernel的新类来注册我的Bundles等。

class AppKernel extends Kernel
{

public function registerBundles()
{
    $bundles=[
        new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        new Symfony\Bundle\MonologBundle\MonologBundle(),
        new Symfony\Bundle\SecurityBundle\SecurityBundle(),
        new mdBundle\mdBundle(),
];
    return $bundles;
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
    $loader->load(function ($container) {
        $container->loadFromExtension('framework', array(
            'secret' => 'some secret here',
            'router' => array(
                'resource' => '%kernel.root_dir%/config/routing.yml'
            ),
            'templating' => array('engines' => array('php'))
        ));
    });
}

}

我的前端控制器如下所示:

include_once(__DIR__ . '/../../app/bootstrap.php');

/**
 * @var Composer\Autoload\ClassLoader $loader
 */
$loader = require '../../app/vendor/autoload.php';

Debug::enable();

$kernel = new AppKernel('dev', true);
//$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

我得到的错误消息如下:输入错误:参数4传递给Symfony \ Component \ HttpKernel \ HttpKernel :: __ construct()必须实现接口Symfony \ Component \ HttpKernel \ Controller \ ArgumentResolverInterface,给出布尔值,在第367行的/var/www/html/app/classes/cache/dev/classesDevDebugProjectContainer.php中调用 我只是不确定如何使用错误的值(值为false" boolean")为参数4创建此文件。

这是我的composer.json文件。

"require": {
        "php": ">=7.0",
        "symfony/console":"v3.0.0",
        "mobiledetect/mobiledetectlib": "2.5.7",
        "zendframework/zend-db": "2.2.5",
        "symfony/dependency-injection": "v3.0.0",
        "symfony/config": "v3.0.0",
        "symfony/yaml": "v2.3.5",
        "phpmailer/phpmailer" : "v5.2.9",
        "smarty/smarty" : "3.1.12",
        "knplabs/knp-snappy": "*",
        "twbs/bootstrap": "3.3.6",
        "phpoffice/phpexcel": "*",
        "moredirect/service": "dev-master",
        "symfony/var-dumper": "2.*",
        "gongo/merciful-polluter": "^0.0.3",
        "solarium/solarium": "^3.5",
        "symfony/framework-bundle": "v3.0.0",
        "symfony/form": "3.0.0",
        "doctrine/doctrine-bundle": "1.6.2",
        "symfony/monolog-bundle": "2.10.0",
        "symfony/security-bundle": "3.0.0",
        "symfony/finder": "3.0.0",
        "symfony/filesystem": "3.0.0",
        "symfony/web-profiler-bundle": "3.0.0",
        "sensio/framework-extra-bundle": "v3.0.0",
        "sensio/distribution-bundle": "3.0.0"
    }

非常感谢任何帮助。 谢谢。

1 个答案:

答案 0 :(得分:7)

原来我在composer.json文件中缺少以下行:

"symfony/http-kernel":"3.0.0"

我添加后它工作正常。谢谢你的所有意见。