Sylius CE Installation
Setting up a fresh Sylius project
The recommended way of creating a new Sylius-based project is to use our Sylius Standard project template.
composer create-project sylius/sylius-standard AcmeStore
This command will create a AcmeStore
directory with the downloaded latest version of Sylius Standard, and install its dependencies. Before we go further, we have to enter the AcmeStore
directory.
cd AcmeStore
Building front-end
Before we perform an initial installation of Sylius, we need to have our front-end assets built. People often use Yarn over npm due to features like workspaces, offline caching, and faster installation times, which can be particularly useful in large-scale or complex projects. However, npm has improved significantly over time and can also be a great choice for managing your front-end packages.
npm install
npm run build
Installing Sylius
To make installing Sylius easier, we provide an interactive process for it. But before we start the installer, we need to define the database's credentials. For the local development, the best choice is to use local .env
files.
To define your database connection string, create the .env.local
file with the following content:
DATABASE_URL=mysql://<username>:<password>@<host>/<your_database_name>_%kernel.environment%?serverVersion=<your_db_version>&charset=utf8
Once you have the database configured, we can run the interactive installer by running the following command in the project's root directory:
bin/console sylius:install
In the first step, Sylius checks whether the system meets the requirements. The second step is dedicated to setting up the database we configured earlier. When the database schema is ready, we can choose whether we want to install the demo data. Next, we go through a basic shop configuration and generate tokens for the Sylius API. At the end, Sylius will automatically install assets from the already installed bundles and plugins.
During the sylius:install
The command will ask you to provide important information, and 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 locale
and sylius_installer_currency
parameters in the config/services.yaml
file. 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.
Configuring Mailer
In order to send emails, you need to configure Mailer Service. Basically, there are multiple ways to do it:
We are recommending using Symfony Mailer, where, out of the box, you can deliver emails by configuring the
MAILER_DSN
variable in your .env file.In Symfony Mailer, use the 3rd-party Transports
(deprecated) Use SwiftMailer with this short configuration:
Create an account on a mailing service.
In your
.env
file modify/add theMAILER_URL
variable.
MAILER_URL=gmail://username:password@local
Accessing the Shop
We strongly recommend using the Symfony Local Web Server by running the symfony server:start
command and then accessing https://127.0.0.1:8000
in your web browser to see the shop.
You can log in 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 machine configurations, etc.var/log/
- These are the logs of your applicationvar/cache/
- This is the cache of your projectsrc/
- This is where you will be adding all your custom logic in theApp
public/
- There, you will be placing the assets of your project
Running asynchronous tasks
To enable asynchronous tasks (for example, for Catalog Promotions), remember to run the messenger consumer in a separate process, use the command:
php bin/console messenger:consume main
For production environments, we suggest the use of a more robust solution like Supervisor, which will ensure that the process is still running even if a failure occurs. For more information, please visit the Symfony documentation.
You can learn more about Catalog Promotions here.
Contributing
If you would like to contribute to Sylius - please go to the Contribution Guide.
Last updated
Was this helpful?