Closed
Description
As stated in the official doc, the current structure of a bundle should be:
<your-bundle>/
├─ AcmeBlogBundle.php
├─ Controller/
├─ README.md
├─ LICENSE
├─ Resources/
│ ├─ config/
│ ├─ doc/
│ │ └─ index.rst
│ ├─ translations/
│ ├─ views/
│ └─ public/
└─ Tests/
Which many developers translate as the following for a repository:
AcmeBlogBundle.php
Controller/
README.md
LICENSE
Resources/
├─ config/
├─ doc/
│ └─ index.rst
├─ translations/
├─ views/
└─ public/
Tests/
with a composer.json
containing:
"autoload": {
"psr-4": { "Acme\\BlogBundle\\": "" }
}
In short, everything at the root. This practice has two harmful results:
- As everything is placed in the root, it easily becomes hard to tell the difference between files related to the source code of the bundle and configuration files such as
composer.json
,.gitignore
,.travis.yml
,behat.yml
,phpunit.xml.dist
and so just to name a few common ones - We include code related to tests in the autoloading even in production mode
Whereas doing the following:
src/
├─ AcmeBlogBundle.php
├─ Controller/
└─ Resources/
├─ config/
├─ doc/
│ └─ index.rst
├─ translations/
├─ views/
└─ public/
tests/
README.md
Resources
composer.json
with:
"autoload": {
"psr-4": { "Acme\\BlogBundle\\": "src" }
},
"autoload-dev": {
"psr-4": { "Acme\\BlogBundle\\Tests\\": "tests" }
}
would address both those issues.
Obviously, changing the architecture of the existing bundles is not always doable as it will break lots of PR and for the bundles which are meant to be used as dev dependencies that's not an issue.
cc @Seldaek
Metadata
Metadata
Assignees
Labels
No labels