Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Closed
Description
As statedin 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.phpController/README.mdLICENSEResources/ ├─ config/ ├─ doc/ │ └─ index.rst ├─ translations/ ├─ views/ └─ public/Tests/with acomposer.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.distand so just to name a few common ones - We include code related to tests in the autoloadingeven in production mode
Whereas doing the following:
src/├─ AcmeBlogBundle.php├─ Controller/└─ Resources/ ├─ config/ ├─ doc/ │ └─ index.rst ├─ translations/ ├─ views/ └─ public/tests/README.mdResourcescomposer.jsonwith:
"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