Skip to content

Commit bcb4076

Browse files
committed
minor symfony#9186 add Prefixing the Names of Imported Routes (ismail1432, javiereguiluz)
This PR was merged into the 3.4 branch. Discussion ---------- add Prefixing the Names of Imported Routes This PR follows this one symfony#9159 Commits ------- f8b8e0d Some fixes and rewords 5ec506d add Prefixing the Names of Imported Routes
2 parents 3137a73 + f8b8e0d commit bcb4076

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

routing/external_resources.rst

+35
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,41 @@ suppose you want to prefix all routes in the AppBundle with ``/site`` (e.g.
133133
The path of each route being loaded from the new routing resource will now
134134
be prefixed with the string ``/site``.
135135

136+
Prefixing the Names of Imported Routes
137+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138+
139+
.. versionadded:: 3.4
140+
The feature to prefix route names was introduced in Symfony 3.4.
141+
142+
You also have the possibility to prefix all route names defined in a controller
143+
class with the ``name`` attribute of the ``@Route`` annotation::
144+
145+
use Symfony\Component\Routing\Annotation\Route;
146+
147+
/**
148+
* @Route(name="blog_")
149+
*/
150+
class BlogController extends Controller
151+
{
152+
/**
153+
* @Route("/blog", name="index")
154+
*/
155+
public function indexAction()
156+
{
157+
// ...
158+
}
159+
160+
/**
161+
* @Route("/blog/posts/{slug}", name="post")
162+
*/
163+
public function showAction(Post $post)
164+
{
165+
// ...
166+
}
167+
}
168+
169+
In this example, the names of the routes will be ``blog_index`` and ``blog_post``.
170+
136171
Adding a Host Requirement to Imported Routes
137172
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138173

0 commit comments

Comments
 (0)