Professional Documents
Culture Documents
Routing en Part1
Routing en Part1
https://symfony.com/components/Routing
Routing
beautiful
URLs!
Fastest
PHP router
available!
4.1
for simple
conditions Imported Routes
Inlined Configuration # config/routes.yaml
app_hello:
you can inline the route requirements resource: '@ThirdPartyBundle/Resources/config/routing.yaml'
host: "hello.example.com”
and default values in the {placeholders}. prefix: /admin
prefix:
blog_list: prefix can
Add prefix en: '/site'
# no requirements and no default value be i18n es: '/sitio'
path: /blog/{page}
to routes
# with requirements but no default value
path: /blog/{page<\d+>}
# no requirements but with a default value
path: /blog/{page?1} Trailing Slash
# no requirements but with default value = null
path: /blog/{page?} Symfony redirect (301 redirect) between URLs with and without trailing slashes
# with requirements and default value = null
in both ways (but only for GET and HEAD requests).
path: /blog/{page<.*>?}
Console
$ php bin/console debug:router visualize and get detailed information about all configured routes
$ php bin/console debug:router article_show visualize and get information of a single route
$ php bin/console router:match /blog/my-latest-post test whether a URL matches a given route