无法在symfony中导入路由

时间:2012-07-31 09:22:02

标签: symfony

我正在使用Jobeet教程。

我已在app / confing文件中配置路由,如下所示:

EnsJobeetBundle:
    resource: "@EnsJobeetBundle/Resources/config/routing.yml"
    prefix:   /

在EnsJobeetBundle路由中,它的定义如下:

EnsJobeetBundle_job:
    resource: "@EnsJobeetBundle/Resources/config/routing/job.yml"
    prefix: /job

当我使用网址http://localhost/Symfony/web/app_dev.php/job/时,我收到以下错误:

Cannot import resource "@EnsJobeetBundle/Resources/config/routing/job.yml" 
 from "C:\wamp\www\Symfony\src\Ens\JobeetBundle/Resources/config/routing.yml". 
Make sure the "EnsJobeetBundle/Resources/config/routing/job.yml" bundle 
 is correctly registered and loaded in the application kernel class.

我也在appkernel文件中注册了如下:

new Ens\JobeetBundle\EnsJobeetBundle(),

可能导致这些错误的原因是什么?

1 个答案:

答案 0 :(得分:0)

就我而言,在尝试生产网址时,我遇到了同样的错误。

在app / AppKernel.php中,有一个条件只考虑'dev'和'test'环境:

   if (in_array($this->getEnvironment(), array('dev', 'test')))

如果你的包也应该在prod环境中启用,你应该修改条件:

   if (in_array($this->getEnvironment(), array('prod', 'dev', 'test')))

这解决了我的错误。