@@ -82,7 +82,7 @@ method to tell Symfony what is the root directory of your bundle path::
8282 {
8383 public function getPath(): string
8484 {
85- return \dirname(__DIR__);
85+ return \dirname(__DIR__); // returns /path/to/Acme/TestBundle/
8686 }
8787 }
8888
@@ -105,8 +105,8 @@ The directory structure of a bundle is meant to help to keep code consistent
105105between all Symfony bundles. It follows a set of conventions, but is flexible
106106to be adjusted if needed:
107107
108- ``src/Controller/ ``
109- Contains the controllers of the bundle (e.g. ``RandomController.php ``).
108+ ``src/ ``
109+ Contains mainly PHP classes related to the bundle logic (e.g. ``Controller/ RandomController.php ``).
110110
111111``config/ ``
112112 Houses configuration, including routing configuration (e.g. ``routing.yaml ``).
@@ -125,6 +125,25 @@ to be adjusted if needed:
125125``tests/ ``
126126 Holds all tests for the bundle.
127127
128+ It's recommended to use the `PSR-4 `_ autoload standard: use the namespace as key,
129+ and the location of the bundle's main class (relative to ``composer.json ``)
130+ as value. As the main class is located in the ``src/ `` directory of the bundle:
131+
132+ .. code-block :: json
133+
134+ {
135+ "autoload" : {
136+ "psr-4" : {
137+ "Acme\\ TestBundle\\ " : " src/"
138+ }
139+ },
140+ "autoload-dev" : {
141+ "psr-4" : {
142+ "Acme\\ TestBundle\\ Tests\\ " : " tests/"
143+ }
144+ }
145+ }
146+
128147 A bundle can be as small or large as the feature it implements. It contains
129148only the files you need and nothing else.
130149
@@ -143,3 +162,4 @@ Learn more
143162* :doc: `/bundles/prepend_extension `
144163
145164.. _`third-party bundles` : https://github.com/search?q=topic%3Asymfony-bundle&type=Repositories
165+ .. _`PSR-4` : https://www.php-fig.org/psr/psr-4/
0 commit comments