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:

🔗 Sylius Plugin Skeletonarrow-up-right

It provides built-in infrastructure for development, testing, and behavior-driven development (BDD) using tools like PHPUnit and Behat.

Plugin Naming Conventions

Sylius plugins follow specific naming conventions depending on whether they are official Sylius plugins or community plugins.

Official Sylius Plugins

For plugins maintained by the Sylius team:

Element
Pattern
Example

Namespace

Sylius\{Feature}Plugin

Sylius\InvoicingPlugin

Package

sylius/{feature}-plugin

sylius/invoicing-plugin

Community Plugins

For plugins developed by the community:

Element
Pattern
Example

Namespace

{Vendor}\Sylius{Feature}Plugin

Acme\SyliusWishlistPlugin

Package

{vendor}/sylius-{feature}-plugin

acme/sylius-wishlist-plugin

circle-info

Including Sylius in the plugin name ensures the configuration key has a sylius_ prefix (e.g., acme_sylius_wishlist), which reduces potential conflicts with other bundles.

Quickstart Guide

1

Create a plugin project

circle-exclamation

After installation, an interactive rename script will automatically run to configure your plugin's namespace and package name according to the naming conventions.

2

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.

circle-info

You can read more about the test application here:

You can initialize it with:

This command:

  • Creates the database and runs migrations

  • Builds frontend assets

  • Loads fixtures

Once initialized, you can run the application with Symfony CLI:

Then open https://127.0.0.1:8000arrow-up-right in your browser.

This setup allows you to quickly verify your plugin behavior in a working Sylius instance without integrating it into another project.

3

Declare Sylius compatibility

Your plugin should explicitly define which versions of Sylius it supports. Add a clear version constraint in composer.json:

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.

4

Implement your plugin functionality

With your plugin cleaned up and renamed, you're ready to start implementing real features.

Last updated

Was this helpful?