提问者:小点点

Symfony2上的FOSJsRoutingBundle安装


我试图通过阅读这个链接上的教程来安装FOSJsRoutingBundle:https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/blob/master/Resources/doc/index.md但是每当我运行这个命令

$ php app/console assets:install --symlink web  

将显示以下错误消息列表:

PHP致命错误:类'FOS\JsRoutingBundle\FOSJsRoutingBundle'未在第19行的C:\wamp\www\日历\app\AppKernel.php中找到

PHP堆栈跟踪:
PHP1。{main}()C:\wamp\www\calendar\app\console:0
PHP2。Symfony\Component\Console\Application-

我不知道为什么它指示类'FOS\JsRoutingBundle\FOSJsRoutingBundle'未找到,尽管该类是在文件应用程序/AppK中声明的ernel.php如下所示:

<?php

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 FOS\JsRoutingBundle\FOSJsRoutingBundle(),
        );

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

        return $bundles;
    }

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

那么,我该如何解决这个问题呢?


共2个答案

匿名用户

添加这一行:

new FOS\JsRoutingBundle\FOSJsRoutingBundle(),

到您的app/AppKernel。php文件。

匿名用户

看起来您已经取出了新AppBundle\AppBundle(),行。。。。将其放在AppKernel中所有捆绑包的末尾,如下所示:

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 FOS\JsRoutingBundle\FOSJsRoutingBundle(),
            new AppBundle\AppBundle(),
        );
    );
);