在 Symfony2 上安装 FOSJsRoutingBundle
Posted
技术标签:
【中文标题】在 Symfony2 上安装 FOSJsRoutingBundle【英文标题】:FOSJsRoutingBundle installation on Symfony2 【发布时间】:2014-05-05 05:00:52 【问题描述】:我已尝试通过阅读此链接上的本教程来安装 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\calendar\app\AppKernel.php 中找到
PHP 堆栈跟踪: 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
我不知道为什么它表明未找到类 'FOS\JsRoutingBundle\FOSJsRoutingBundle' 尽管在文件 app/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');
那么,我该如何解决这个问题呢?
【问题讨论】:
你跑composer.phar update
了吗?
是的,但是当我运行此命令时:$ php app/console assets:install --symlink web 再次,我看到此错误消息:[Symfony\Component\Filesystem\Exception\IOException]由于错误代码 1314,无法创建符号链接:“客户端未持有所需的权限”。您是否拥有所需的管理员权限?
您是否有权创建符号链接?
其实我不知道……我怎么知道???提前致谢。
根据您上面评论中的错误,您没有权限。您可以尝试不使用--symlink
选项吗?你的问题解决了吗?
【参考方案1】:
添加这一行:
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
到您的app/AppKernel.php
文件。
【讨论】:
【参考方案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(),
);
);
);
【讨论】:
以上是关于在 Symfony2 上安装 FOSJsRoutingBundle的主要内容,如果未能解决你的问题,请参考以下文章