How justteshi/sylius-tutorial works
The Sylius Standard Edition is a fully featured, decoupled eCommerce framework built on top of Symfony and Doctrine. Its purpose is to provide a highly flexible, scalable platform for building custom eCommerce solutions. The project’s file tree and README indicate that it is a full-stack application with clearly separated frontend and backend components, comprehensive configuration management, and containerized deployment support via Docker.
Main Components
• Frontend:
• Assets: Two key directories (assets/admin and assets/shop) hold the JavaScript entry points for the administration and storefront interfaces. These are built using tools like Webpack (see webpack.config.js and webpack_encore.yaml), and yarn is used for dependency management.
• Public: The public/ directory contains index.php and other publicly accessible files (like .htaccess) which serve as the entry point for incoming HTTP requests.
• Backend:
• Symfony Application: Most of the business logic lives in the src/ directory with controllers, entities (organized by domain like Order, Product, User, etc.), and a Kernel (src/Kernel.php) that bootstraps the application.
• Configuration: The config/ directory contains various sub-directories and files that configure bundles, API Platform (a REST API backend), security, Doctrine (ORM) settings, routing, and other environment-specific configurations.
• Services: Service definitions are included in config/services.yaml and corresponding test files (services_test.yaml) to tailor dependency injection for different environments.
• Database & Persistence:
• Doctrine ORM: Entities in src/Entity are mapped for relational DB storage via Doctrine. Migrations (in src/Migrations) help with schema versioning and evolution.
• APIs & External Integrations:
• API Platform: Configured under config/api_platform for exposing a robust REST API.
• External Libraries: Integration with JWT, FOS REST, and other bundles, which are configured in various YAML files.
• Testing & Development Tools:
• BDD Tools: Behat (features) and PHPSpec (phpspec.yaml.dist) demonstrate a behavior-driven-development workflow.
• Continuous Integration: GitHub workflows under .github/workflows and CI configurations like ecs.php and phpstan.neon ensure code quality.
• Deployment & Containerization:
• Docker: Multiple Docker-related files (Dockerfile, docker-compose.yml, docker-compose.prod.yml, and subfolders under docker/) indicate that the application is containerized. Separate configurations exist for development and production environments.
Relationships and Interactions
• Client Interaction:
• Users access the frontend (both Shop and Admin interfaces) via a web browser that loads the application from the public directory.
• The assets (JavaScript, CSS) are built and served by a Node/webpack service that communicates back to the Symfony backend.
• Backend Processing:
• HTTP requests reach the Symfony application (via index.php in public/) that routes them through the controllers in src/Controller.
• The controllers interact with business logic (entities, services, repositories) and trigger database operations through Doctrine.
• API Exposure:
• API Platform exposes endpoints from configured entities, allowing for external integrations and modern frontend frameworks to consume data.
• Dockerized Environment:
• Docker containers are used for PHP (with separate configurations for production and development), Nginx (as the web server), Node (for asset building), and possibly a database container.
• Testing & CI:
• Automated testing is integrated via PHPUnit, Behat, and PHPSpec. CI workflows manage builds, tests, and deployments.
Architectural Patterns and Design Principles
• Decoupled Architecture: Frontend assets and backend are clearly separated.
• Domain-Driven Design: The entity structure in src/Entity is organized by domain (e.g., Order, Product, User) to encapsulate business logic.
• Service-Oriented: The dependency injection and extensive use of external bundles promote modularity and reusability.
• Containerization: The use of Docker and separate configuration files for various environments supports agile and consistent deployments across environments.