2
votes

I use example from docs. This is routing.yml:

   app:
    resource: '@AppBundle/Controller/'
    type: annotation
    blog_list:
        path:      /blog/{page}
        defaults:  { _controller: AppBundle:Blog:list , page: 1}
        requirements:
            page: '\d+'

And this controller:

<?php
    namespace AppBundle\Controller;

    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
    use Symfony\Component\HttpFoundation\Response;
    use Symfony\Bundle\FrameworkBundle\Controller\Controller;
    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

    class BlogController extends Controller
    {
        /**
         * @Route("/blog/{page}", name="blog_list", requirements={"page": "\d+"})
         */
        public function listAction($page = 1)
        {
            $number = mt_rand(0, 100);
            return $this->render('lucky/number.html.twig',['number'=>$number]);
        }
    }

I see errors:

The routing file "/var/www/pars/app/config/routing.yml" contains unsupported keys for "app": "blog_list". Expected one of: "resource", "type", "prefix", "path", "host", "schemes", "methods", "defaults", "requirements", "options", "condition" in /var/www/pars/app/config/routing.yml (which is being imported from "/var/www/pars/app/config/routing_dev.yml").

WHY?

1

1 Answers

2
votes

Seems only an indentation problem: the new route should be at the low level:

app:
    resource: '@AppBundle/Controller/'
    type: annotation

blog_list:
    path:      /blog/{page}
    defaults:  { _controller: AppBundle:Blog:list , page: 1}
    requirements:
        page: '\d+'

Hope this help