The Sylius main application can serve as an end-user app, as well as a foundation for your custom e-commerce application.
To create your Sylius-based application, first make sure you use PHP 8.0 or higher and have Composer installed.
In order to inform you about newest Sylius releases and be aware of shops based on Sylius, the Core Team uses an internal statistical service called GUS. The only data that is collected and stored in its database are hostname, user agent, locale, environment (test, dev or prod), current Sylius version and the date of last contact. If you do not want your shop to send requests to GUS, please visit this guide for further instructions.
Initiating A New Sylius Project¶
To begin creating your new project, run this command:
composer create-project sylius/sylius-standard acme
Make sure to use PHP ^8.0. Using an older PHP version will result in installing an older version of Sylius.
This will create a new Symfony project in the
acme directory. Next, move to the project directory:
Sylius uses environment variables to configure the connection with database and mailer services.
You can look up the default values in
.env file and customise them by creating
.env.local with variables you want to override.
For example, if you want to change your database name from the default
the contents of that new file should look like the following snippet:
Specific Sylius versions may support various Symfony versions. To make sure the correct Symfony version will be installed (Symfony 6.0 for example) use:
composer config extra.symfony.require "^6.0" composer update
Otherwise, you may face the problem of having Symfony components of the wrong version installed.
After everything is in place, run the following command to install Sylius:
php bin/console sylius:install
sylius:install command you will be asked to provide important information, but also its execution ensures
that the default currency (USD) and the default locale (English - US) are set.
They can be changed later, respectively in the “Configuration > Channels” section of the admin and in the
config/services.yaml file. If you want
to change these before running the installation command, set the
sylius_installer_currency parameters in the
From now on all the prices will be stored in the database in USD as integers, and all the products will have to be added with a base american english name translation.
In order to send emails you need to configure Mailer Service. Basically you need to:
- Create an account on a mailing service.
- In your
.envfile modify the
Email delivery is disabled for test, dev and staging environments by default. The prod environment has delivery turned on.
You can learn more about configuring mailer service in How to configure mailer?
In order to see a fully functional frontend you will need to install its assets.
If you want to read more, you can read a chapter of our Book devoted to the Sylius’ frontend.
Having Yarn installed, go to your project directory to install the dependencies:
Then build the frontend assets by running:
Accessing the Shop¶
We strongly recommend using the Symfony Local Web Server by running the
command and then accessing
http://127.0.0.1:8000 in your web browser to see the shop.
You can log to the administrator panel located at
/admin with the credentials you have provided during the installation process.
How to start developing? - Project Structure¶
After you have successfully gone through the installation process of Sylius-Standard you are probably going to start developing within the framework of Sylius.
In the root directory of your project you will find these important subdirectories:
config/- here you will be adding the yaml configuration files including routing, security, state machines configurations etc.
var/log/- these are the logs of your application
var/cache/- this is the cache of you project
src/- this is where you will be adding all you custom logic in the
public/- there you will be placing assets of your project
Running asynchronous tasks¶
To enable asynchronous tasks (for example for Catalog Promotions), remember about running messenger consumer in a separate process, use the command: php bin/console messenger:consume main
For production environments, we suggest usage of more robust solution like Supervisor, which will ensure that the process is still running even if some failure will occur. For more information, please visit Symfony documentation.
You can learn more about Catalog Promotions Here