Welcome, 🤖 AI assistant! Please follow these guidelines when contributing to this Sylius:
- This is Sylius: e-commerce framework
- Sylius is built on top of Symfony
- Sylius must be easily extendable in the end application
- Sylius contains Bundles and Components that can be used independently
- Sylius is designed to be modular and flexible
- Sylius is designed to be fast and efficient
- Follow the Sylius Backward Compatibility (BC) policy
- Ensure compatibility with Symfony and PHP versions defined in
composer.json - For API configuration, use API Platform 4.x
- Follow secure coding practices to prevent XSS, CSRF, injections, auth bypasses, etc.
- Use 4 spaces for indentation in all files (PHP, YAML, XML, Twig, etc.)
- Use PHPUnit for unit and functional testing
- Use Behat for behavior-driven scenarios
- Use ECS to ensure consistent code style
- Use PHPStan for static analysis
- Use CI to run all tests and checks automatically
- Run
composer installto install PHP dependencies - Run
vendor/bin/ecsto fix PHP code style issues - Run
vendor/bin/phpstan analyseto perform static analysis - Run
vendor/bin/phpunitto execute unit and functional tests - Run
yarn installto install JavaScript dependencies - Run
yarn encore devto compile frontend assets
- Use modern PHP 8.2+ syntax and features
- Declare
strict_types=1in all PHP files - Follow the Sylius Coding Standard
- Do not use deprecated features from PHP, Symfony, or Sylius
- Use
finalfor all classes, except entities and repositories - Use
readonlyfor immutable services and value objects - Add type declarations for all properties, arguments, and return values
- Use
camelCasefor variables and method names - Use
SCREAMING_SNAKE_CASEfor constants - Use
snake_casefor configuration keys, route names, and template variables - Use fast returns instead of nesting logic unnecessarily
- Use trailing commas in multi-line arrays and argument lists
- Order array keys alphabetically where applicable
- Use PHPDoc only when necessary (e.g.
@var Collection<ProductInterface>) - Group class elements in this order: constants, properties, constructor, public methods, protected methods, private methods
- Group getter and setter methods for the same properties together
- Suffix interfaces with Interface, traits with Trait
- Use
usestatements for all non-global classes - Sort
useimports alphabetically and group by type (classes, functions, constants)
- Use modern HTML5 syntax
- Always use the most modern Twig syntax and features
- Icon names must be from the Tabler 1.x library
- Use
snake_casefor all template directory and file names - Use
snake_casefor all variable names in Twig files - Ensure the directory structure under
templates/matches the structure of the corresponding Twig hooks - Use translations for all strings in templates, never hardcode text
- Define resources in
admin/andshop/folders accordingly - Define operations in the following order:
get collection,get item,post,put,patch,delete - Define resource serialization in the
serialization/folder - Use serialization groups for:
index,show,create,update - Use PHPUnit tests to validate API configuration and API responses
- Use SCSS (
.scss) syntax – plain CSS files are not allowed - Use Bootstrap 5 utility classes where possible
- Keep component styles modular – 1 component = 1 partial
- Use variables from Sylius theme
- Place all theme variables in
_variables.scss - Avoid
!importantunless absolutely necessary - Prefer
removerpxfor spacing, font size, etc. - Use
mixins/for reusable logic (e.g.,@include icon-size(24px))