【发布时间】:2014-03-26 03:23:22
【问题描述】:
我正在学习使用 symfony 和教义,但我遇到了一个我找不到解决方案的问题。 这是关于路由文件的。我有一个名为“LinkBundle”的包,其中我在“LinkBundle/Resources/config/routing.yml”中创建了一个“routing.yml”文件
在 app/resources 中有我的路由文件:
projet_php_link:
resource: "@ProjetPhpLinkBundle/Resources/config/routing.yml"
type: annotation
prefix: /
当我访问我的网站时,出现以下错误:
无法加载资源 “@ProjetPhpLinkBundle/Resources/config/routing.yml”。确保 “ProjetPhpLinkBundle/Resources/config/routing.yml”捆绑包是正确的 在应用程序内核类中注册并加载。
有我的 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 ProjetPhp\Bundle\UserBundle\ProjetPhpUserBundle(),
new ProjetPhp\Bundle\LinkBundle\ProjetPhpLinkBundle(),
new ProjetPhp\Bundle\TagBundle\ProjetPhpTagBundle(),
new FOS\UserBundle\FOSUserBundle(),
);
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;
}
你能帮帮我吗?
【问题讨论】:
-
检查大写字母,有时会出现拼写错误。
-
其实我是symfony新手,但是如果加载资源类型注解,不就是xlm文件吗?为什么是yml文件?
-
我尝试在类型字段中放置“yml”而不是“annotation”。我有同样的错误。
-
尝试擦除类型字段,不要认为它是强制性的。也尝试显示导入的文件
-
当我删除类型字段和前缀字段时它工作了,感谢您的帮助;)