🆕How to Create a Plugin for Sylius?
A Sylius plugin is simply a standard Symfony bundle that extends the core Sylius behavior. The recommended way to start developing your own plugin is by using the official plugin skeleton:
It provides built-in infrastructure for development, testing, and behavior-driven development (BDD) using tools like PHPUnit and Behat.
Quickstart Guide
Test the plugin via the built-in Test Application
The Plugin Skeleton includes a ready-to-use TestApplication provided by the sylius/test-application
package. This is a minimal Sylius application used for testing and previewing your plugin in isolation.
You can initialize it with:
composer test-app-init
This command:
Creates the database and runs migrations
Builds frontend assets
Loads fixtures
Once initialized, you can run the application with Symfony CLI:
symfony serve -d
Then open https://127.0.0.1:8000 in your browser.
This setup allows you to quickly verify your plugin behavior in a working Sylius instance without integrating it into another project.
Declare Sylius compatibility
Your plugin should explicitly define which versions of Sylius it supports. Add a clear version constraint in composer.json
:
"require": {
"sylius/sylius": "^2.0"
}
to avoid installation in incompatible environments. Make sure to test your plugin’s behaviour across the intended Sylius versions using the built-in Test Application.
Last updated
Was this helpful?