0
votes

I'm learning to use symfony and doctrine and I'm facing to a problem I can't find a solution. It's about routing files. I have a bundle named "LinkBundle" in which I created a "routing.yml" file into "LinkBundle/Resources/config/routing.yml"

There is my routing file into app/resources :

projet_php_link:
resource: "@ProjetPhpLinkBundle/Resources/config/routing.yml"
type:     annotation
prefix:   /

When I go to my website, I have the following error :

Cannot load resource "@ProjetPhpLinkBundle/Resources/config/routing.yml". Make sure the "ProjetPhpLinkBundle/Resources/config/routing.yml" bundle is correctly registered and loaded in the application kernel class.

There is my 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;
    }

Can you help me ?

1
Check the upper-case letter, sometimes a typo about it happens.Gianni Alessandro
Actually I'm new of symfony, but if you load resource type annotation, doesn't it be a xlm file? Why it is an yml file?Gianni Alessandro
I tried to put "yml" instead of "annotation" in the type field. I have the same error.user2302725
Try to erase the type field, don't think it is mandatory. Try also to show the imported fileGianni Alessandro
It worked when I erased type field and prefix field, thanks for your help ;)user2302725

1 Answers

0
votes

Actually it's simple. You setup annotations but require YAML. You need to decide which one you want:

Annotations in controllers:

projet_php_link:
  resource: "@ProjetPhpLinkBundle/Controller/"
  type:     annotation
  prefix: /

or in routing.yml

projet_php_link:
  resource: "@ProjetPhpLinkBundle/Resources/Config/routing.yml"
  prefix: /