10000 add Prefixing the Names of Imported Routes by ismail1432 · Pull Request #9186 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

add Prefixing the Names of Imported Routes #9186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add Prefixing the Names of Imported Routes
This PR follows this one #9159
  • Loading branch information
ismail1432 authored Feb 1, 2018
commit 5ec506dd475866d243db58881a8a98d81ebbe6c6
25 changes: 25 additions & 0 deletions routing/external_resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,31 @@ suppose you want to prefix all routes in the AppBundle with ``/site`` (e.g.
The path of each route being loaded from the new routing resource will now
be prefixed with the string ``/site``.

Prefixing the Names of Imported Routes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You have the possibility to prefix all routes names with the ``@Route`` annotation.
Add a ``name`` property to the ``@Route`` annotation of the controller class and that will be considered the prefix of all route names

.. code-block:: php
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

/**
* @Route("/blog", name="blog_")
*/
class BlogController extends Controller
{
/**
* @Route("/", defaults={"page": "1"}, name="index")
* @Route("/page/{page}", name="index_paginated")
*/
public function indexAction($page, $_format) { ... }

/**
* @Route("/posts/{slug}", name="post")
*/
public function showAction(Post $post) { ... }
}

Adding a Host Requirement to Imported Routes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
0