phpsymfony

Symfony2: Routing priority


is there anyway to prioritize routes in Symfony2?

i'm using annotation it looks like this

Controllers

//TestController.php

/**
 * @Route("/test")
 */
class TestController extends Controller
{
    /**
     * @Route("/a", name="test_a")
     */
   .....

//DummyController.php
/**
 * @Route("/")
 */
class DummyController extends Controller
{
    /**
      * @Route("/{varA}/{varB}", name="dummy_one")
      */
   .....

Config

//routing.yml

acme_bundle:
    resource: "@Acme/Controller"
    type:     annotation

Goal

URL      , Actual              , Goal
/test/a  , DummyController     , TestController  //Wrong
/test/b  , DummyController     , DummyController //Good

How can i force TestController to be tested first ?

Thanks


Solution

  • So Symfony will consume the controllers in an alphabetical order and will add the routes one by one.

    there is no way up to add priority at the moment without using another bundle for that currently version 2.5

    https://github.com/symfony-cmf/Routing is a great bundle if you are looking for advanced routing.