Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm explaining here what's the concept behind this pull request because it will be linked in my talk and also because it should be used for a future documentation.
The importers
The "importer" is just a name I gave to these sort of "front controllers".
These files should be used when our configuration files contain different roots.
Using these simple
.php
files some things can be prevented:imports
, we can write just a- resource bundles/imports.php
imports.php
file can be called as we want, and the best solution should be the root of the bundle configuration we are writingOverrides
The less our configuration files contain, the better it is! Sometimes there are different ways to write a configuration:
This is the most simple case, here we don't want the confirmation email while we're developing, so it's required only in production.
Everything seems ok, but there's a wrong assertion behind:
dev == test == * != prod
.In fact if we want to test the confirmation email, the configuration has to be duplicated and we don't know if the test has to depend from the development environment or the production environment (if we don't have a sender address in dev, what should be used?).
This is the kind of configuration organization you can find in the
symfony/symfony-standard
and it's better than the first: if we don't want repeat our configuration (e.g. the from_email) we simply need to override it in the chosen environment.By defining the
confirmation_enabled
parameter in ourparameters.yml.dist
, it can be based on the environment, so the test environment can be really independent from the prod and dev environments (and overridden if theconfirmation_from_email
isn't the same of dev).Tip
If you're creating a bundle that requires a configuration, try to use parameters too, like the DoctrineCacheBundle does:
isn't the same of
Naming Strategy
Naming strategies are different and depend on what should be identified.
If a class is used as a service then the identifier is the full namespace lowercase, with and underscore separating uppercase letters and a dot instead of the backslash, so for example VendorBundle\Package\LibraryController become vendor_bundle.package.library_controller
If something must refer to a configuration, try to use the full configuration tree, for example:
Tip: Always look the bundle configuration, the last half of this example can be prevented if you know the existence of the service
doctrine.orm.default_metadata_cache
! ;)