FOSJsRoutingBundle installation on Symfony2

纵饮孤独 提交于 2019-12-13 01:34:46

问题


I have tried to install FOSJsRoutingBundle through reading this tutorial on this link: https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/blob/master/Resources/doc/index.md but whenever I run this command

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

the following list of errors messages is displayed:

PHP Fatal error: Class 'FOS\JsRoutingBundle\FOSJsRoutingBundle' not found in C:\wamp\www\calendar\app\AppKernel.php on line 19

PHP Stack trace:
PHP 1. {main}() C:\wamp\www\calendar\app\console:0
PHP 2. Symfony\Component\Console\Application->run() C:\wamp\www\calendar\app\console:27
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() C:\wamp\www\calendar\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:121
PHP 4. Symfony\Component\HttpKernel\Kernel->boot() C:\wamp\www\calendar\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:70
PHP 5. Symfony\Component\HttpKernel\Kernel->initializeBundles() C:\wamp\www\calendar\app\bootstrap.php.cache:2269
PHP 6. AppKernel->registerBundles() C:\wamp\www\calendar\app\bootstrap.php.cache:2439

I don't know why it indicates that the class 'FOS\JsRoutingBundle\FOSJsRoutingBundle' not found is not found despite that class is declared at the file app/AppKernel.php as you can notice below:

<?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');
    }
}

So, how can I resolve this problem?


回答1:


Add this line:

new FOS\JsRoutingBundle\FOSJsRoutingBundle(),

to your app/AppKernel.php file.




回答2:


It looks like you've taken out the new AppBundle\AppBundle(), line out.... put it at the end of all the bundles in your AppKernel like below:

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(),
        );
    );
);


来源:https://stackoverflow.com/questions/22666989/fosjsroutingbundle-installation-on-symfony2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!