8000 [DI] Documenting Abstract Bundle and Extension by yceruto · Pull Request #16801 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[DI] Documenting Abstract Bundle and Extension #16801

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 9 commits into from
May 27, 2022
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
Prev Previous commit
Next Next commit
Update bundle.rst
  • Loading branch information
yceruto committed May 21, 2022
commit c2c47a21f63b2a5e387f7ca17e4920d8d164750e
26 changes: 23 additions & 3 deletions bundles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ method to tell Symfony what is the root directory of your bundle path::
{
public function getPath(): string
{
return \dirname(__DIR__);
return \dirname(__DIR__); // returns /path/to/Acme/TestBundle/
}
}

Expand All @@ -105,8 +105,8 @@ The directory structure of a bundle is meant to help to keep code consistent
between all Symfony bundles. It follows a set of conventions, but is flexible
to be adjusted if needed:

``src/Controller/``
Contains the controllers of the bundle (e.g. ``RandomController.php``).
``src/``
Contains mainly PHP classes related to the bundle logic (e.g. ``Controller/RandomController.php``).

``config/``
Houses configuration, including routing configuration (e.g. ``routing.yaml``).
Expand All @@ -125,6 +125,25 @@ to be adjusted if needed:
``tests/``
Holds all tests for the bundle.

It's recommended to use the `PSR-4`_ autoload standard: use the namespace as key,
and the location of the bundle's main class (relative to ``composer.json``)
as value. As the main class is located in the ``src/`` directory of the bundle:

.. code-block:: json

{
"autoload": {
"psr-4": {
"Acme\\TestBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Acme\\TestBundle\\Tests\\": "tests/"
}
}
}

A bundle can be as small or large as the feature it implements. It contains
only the files you need and nothing else.

Expand All @@ -143,3 +162,4 @@ Learn more
* :doc:`/bundles/prepend_extension`

.. _`third-party bundles`: https://github.com/search?q=topic%3Asymfony-bundle&type=Repositories
.. _`PSR-4`: https://www.php-fig.org/psr/psr-4/
0