Skip to content

Commit 7829a0e

Browse files
committed
minor #18904 Reword the contents about bundles' logical paths (javiereguiluz)
This PR was merged into the 5.4 branch. Discussion ---------- Reword the contents about bundles' logical paths This fixes #15419 according to `@stof`'s comment in #15419 (comment) Commits ------- 58311ef Reword the contents about bundles' logical paths
2 parents 11896e0 + 58311ef commit 7829a0e

File tree

3 files changed

+16
-30
lines changed

3 files changed

+16
-30
lines changed

bundles/best_practices.rst

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -537,16 +537,12 @@ Resources
537537
---------
538538

539539
If the bundle references any resources (config files, translation files, etc.),
540-
don't use physical paths (e.g. ``__DIR__/config/services.xml``) but logical
541-
paths (e.g. ``@AcmeBlogBundle/config/services.xml``).
540+
you can use physical paths (e.g. ``__DIR__/config/services.xml``).
542541

543-
The logical paths are required because of the bundle overriding mechanism that
544-
lets you override any resource/file of any bundle. See :ref:`http-kernel-resource-locator`
545-
for more details about transforming physical paths into logical paths.
546-
547-
Beware that templates use a simplified version of the logical path shown above.
548-
For example, an ``index.html.twig`` template located in the ``templates/Default/``
549-
directory of the AcmeBlogBundle, is referenced as ``@AcmeBlog/Default/index.html.twig``.
542+
In the past, we recommended to only use logical paths (e.g.
543+
``@AcmeBlogBundle/config/services.xml``) and resolve them with the
544+
:ref:`resource locator <http-kernel-resource-locator>` provided by the Symfony
545+
kernel, but this is no longer a recommended practice.
550546

551547
Learn more
552548
----------

bundles/override.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ When using a third-party bundle, you might want to customize or override some of
55
its features. This document describes ways of overriding the most common
66
features of a bundle.
77

8-
.. tip::
9-
10-
The bundle overriding mechanism means that you cannot use physical paths to
11-
refer to bundle's resources (e.g. ``__DIR__/config/services.xml``). Always
12-
use logical paths in your bundles (e.g. ``@FooBundle/Resources/config/services.xml``)
13-
and call the :ref:`locateResource() method <http-kernel-resource-locator>`
14-
to turn them into physical paths when needed.
15-
168
.. _override-templates:
179

1810
Templates

components/http_kernel.rst

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -715,19 +715,17 @@ Locating Resources
715715
------------------
716716

717717
The HttpKernel component is responsible of the bundle mechanism used in Symfony
718-
applications. The key feature of the bundles is that they allow to override any
719-
resource used by the application (config files, templates, controllers,
720-
translation files, etc.)
721-
722-
This overriding mechanism works because resources are referenced not by their
723-
physical path but by their logical path. For example, the ``services.xml`` file
724-
stored in the ``Resources/config/`` directory of a bundle called FooBundle is
725-
referenced as ``@FooBundle/Resources/config/services.xml``. This logical path
726-
will work when the application overrides that file and even if you change the
727-
directory of FooBundle.
728-
729-
The HttpKernel component provides a method called :method:`Symfony\\Component\\HttpKernel\\Kernel::locateResource`
730-
which can be used to transform logical paths into physical paths::
718+
applications. One of the key features of the bundles is that you can use logic
719+
paths instead of physical paths to refer to any of their resources (config files,
720+
templates, controllers, translation files, etc.)
721+
722+
This allows to import resources even if you don't know where in the filesystem a
723+
bundle will be installed. For example, the ``services.xml`` file stored in the
724+
``Resources/config/`` directory of a bundle called FooBundle can be referenced as
725+
``@FooBundle/Resources/config/services.xml`` instead of ``__DIR__/Resources/config/services.xml``.
726+
727+
This is possible thanks to the :method:`Symfony\\Component\\HttpKernel\\Kernel::locateResource`
728+
method provided by the kernel, which transforms logical paths into physical paths::
731729

732730
$path = $kernel->locateResource('@FooBundle/Resources/config/services.xml');
733731

0 commit comments

Comments
 (0)