我正在学习使用symfony和doctrine,我遇到了一个我无法找到解决方案的问题。 这是关于路由文件。我有一个名为“LinkBundle”的包,我在其中创建了一个“routing.yml”文件到“LinkBundle / Resources / config / routing.yml”
我的路由文件存入app / resources:
projet_php_link:
resource: "@ProjetPhpLinkBundle/Resources/config/routing.yml"
type: annotation
prefix: /
当我访问我的网站时,出现以下错误:
无法加载资源 “@ ProjetPhpLinkBundle /资源/配置/ 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;
}
你能帮助我吗?
答案 0 :(得分:0)
实际上很简单。您设置注释但需要YAML。你需要决定你想要哪一个:
控制器中的注释:
projet_php_link:
resource: "@ProjetPhpLinkBundle/Controller/"
type: annotation
prefix: /
或在routing.yml
中projet_php_link:
resource: "@ProjetPhpLinkBundle/Resources/Config/routing.yml"
prefix: /