在Symfony2的FOSJsRoutingBundle安装(FOSJsRoutingBundle

2019-10-19 16:23发布

我曾尝试通过此链接阅读本教程安装FOSJsRoutingBundle: https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/blob/master/Resources/doc/index.md但每当我运行此命令

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

显示以下错误信息列表:

PHP致命错误:类 'FOS \ JsRoutingBundle \ FOSJsRoutingBundle' 未发现在C:\瓦帕\ WWW \日历\应用\上线19 AppKernel.php

PHP堆栈跟踪:
PHP 1. {主}()C:\瓦帕\ WWW \日历\应用\控制台:0
PHP 2的Symfony \元器件\控制台\应用 - > run()的C:\瓦帕\ WWW \日历\应用\控制台:27
PHP 3的Symfony \捆绑\ FrameworkBundle \控制台\应用 - > doRun()C:\瓦帕\ WWW \日历\厂商\ symfony的\ symfony的\ SRC \的Symfony \元器件\控制台\ Application.php:121
PHP 4的Symfony \元器件\ HttpKernel \内核级>引导()C:\瓦帕\ WWW \日历\厂商\ symfony的\ symfony的\ SRC \的Symfony \捆绑\ FrameworkBundle \控制台\ Application.php:70
PHP 5的Symfony \元器件\ HttpKernel \内核级> initializeBundles()C:\瓦帕\ WWW \日历\应用\ bootstrap.php.cache:2269
PHP 6. AppKernel-> registerBundles()C:\瓦帕\ WWW \日历\应用\ bootstrap.php.cache:2439

我不知道为什么它表明类的FOS \ JsRoutingBundle \ FOSJsRoutingBundle'没有发现尽管类是在文件的应用程序中声明没有找到/ AppKernel.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');
    }
}

所以,我怎样才能解决这个问题呢?

Answer 1:

加入这一行:

new FOS\JsRoutingBundle\FOSJsRoutingBundle(),

你的app/AppKernel.php文件。



Answer 2:

它看起来像你已经采取了new 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(),
        );
    );
);


文章来源: FOSJsRoutingBundle installation on Symfony2