- We recommend using YAML (
*.yaml) for defining routings and configs. - We recommend using XML (
*.xml) for defining services, doctrine mappings, and validation definitions. - If you prefer handling points 1 and 2 differently, please do it consistent in entire project.
- For services definitions in a single bundle use
form.xml,event_listener.xml, etc. Don't put everything in theservices.xmlfile, do it in public projects with only a few services. If you have more than one type of service Inside your app, create a separate config file under theservices/directory. - Any information regarding external system (like DSN, service path) have to been placed in
.envfile as placeholders. If you consider putting there any credentials, please put only empty placeholders there. - Please use
.env.local(which is not commited to the repository) file for all sensitive and environment-specific data. - Use finals everywhere you can (specially in non-bundle projects).
- Repositories and entities in public projects should not (and cannot) be defined as
final. - Interface-driven development is not welcome, but if you consider extending your class or overriding your service, please use traits and interfaces.
- Entity fields in public projects (vendors) should be
protectedinstead ofprivate. - Decorate resource factories with decoration pattern and do not call resource instance with
newkeyword directly. Instead, inject resource factory into the constructor and callcreateNew()on it. SeeSylius\Component\Product\Factory\ProductFactory,sylius.custom_factory.productservice definition and Symfony Service Decoration. Thepriorityflag we are starting with equals 1 and is increased by one for each other decoration. - Don't include the entire service container into your service by default, if you don't have to. Instead of that use Symfony Dependency Injection.
- For customizing forms use Symfony Form Extension.
- We don't use either autowire nor autoconfigure Symfony options as it is a very "magic" way of defining services. We always prefer to manually define services and inject proper arguments into them to have better control of our Container. # To be discussed
- Do not define services as public, if it's not necessary.
- Don't use Sylius theme if you have one template in your project.