diff --git a/routing/external_resources.rst b/routing/external_resources.rst index 37242053b6c..d89c9c30e30 100644 --- a/routing/external_resources.rst +++ b/routing/external_resources.rst @@ -133,6 +133,41 @@ 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 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 3.4 + The feature to prefix route names was introduced in Symfony 3.4. + +You also have the possibility to prefix all route names defined in a controller +class with the ``name`` attribute of the ``@Route`` annotation:: + + use Symfony\Component\Routing\Annotation\Route; + + /** + * @Route(name="blog_") + */ + class BlogController extends Controller + { + /** + * @Route("/blog", name="index") + */ + public function indexAction() + { + // ... + } + + /** + * @Route("/blog/posts/{slug}", name="post") + */ + public function showAction(Post $post) + { + // ... + } + } + +In this example, the names of the routes will be ``blog_index`` and ``blog_post``. + Adding a Host Requirement to Imported Routes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~