How I survived Sylius installation

Serdar Dere
6 min readSep 21, 2022

--

https://docs.sylius.com/en/latest/_images/logo_big.png

When I was looking for an open source e-commerce platform few weeks ago, I somehow discovered Sylius. I mean I also checked the big players like WooCommerce and Magento, and I also found a very interesting project named shopizer. But, you know, sometime you have this feeling in your guts, which tells you it does not work for you, although shopizer is written in Java. So while checking out Sylius I saw this on the sylius-standard github account:

“Sylius is the first decoupled eCommerce platform based on Symfony and Doctrine. The highest quality of code, strong testing culture, built-in Agile (BDD) workflow and exceptional flexibility make it the best solution for application tailored to your business requirements.”

I was immediatly triggered because of the “decoupled eCommerce platform” or “Open Source Headless eCommerce Platform” how it is described on sylius.com.

So I started to read and install it on my server and this is how my dependency hell started.

Actually I am a Java Developer and am not familar with PHP, so I needed to figure out what these Symfony and Doctrine are.

My simple minded answer for this is: Symfony is similar to Spring (or just Spring MVC) and Doctrine can be compared to JPA.

To begin with sylius I was looking for the docs and tried https://docs.sylius.com/ and bingo there it was.

I appreciate this kind of unwritten codex to use docs.DOMAIN.tld for documentation, it makes it very easy to find them.

Now let’s get started..

The first thing I did was creating runuser and group and create a directory.

My standard is /var/apphome/NUMBER_APP I called this one shop and it is my 19 application I installed, therefore /var/apphome/019_shop is my directory.
I also prepared a reverse proxy using apache on port 8000, but I will not go in detail how to do this, there are lot of tutorials available int the internet and different tastes of reverse proxies.

Back to business: while going through the prerequisites checklist

https://docs.sylius.com/en/latest/_images/installation_checklist.png

First I stumbled at composer(php) and yarn(js/ts) and from my understanding they both are package manager.
Therefore I installed them as described here: https://getcomposer.org/download/ and here https://yarnpkg.com/getting-started/install

Now that we fulfilled the prerequisites let’s get cookin’ with the first command composer create-project sylius/sylius-standard shop .
After a lot of locking I ended up at

and selected yes because of the explanation.
This one takes ca. 5 Minutes and displays a bunch of community selected plugins.

Right after successfully installing sylius I wanted to start it, but I needed a db, therefore I created a user sylius, a db which I also named sylius and a superdupersecretpassword.

Sylius uses a file named .env for its environmental variables, so I checked that and replaced the DATABASE line with my setting.

DATABASE_URL=mysql://sylius:superdupersecretpassword@127.0.0.1/sylius_%kernel.environment%

So I continued with the documentation and hit this command into the console php bin/console sylius:install .

And here comes my lack of knowledge about php, I thought I already installed sylius, but this command proved me wrong. And here is the beautiful sylius swan, which tells me that there are 5 steps to go to complete the installation

Oh boy this looks huge. YES destroy my tables!!!

Great it installs sample data. From what I understand here is, that my db will be erased again, but go for it.

I have to admit this is a very nice user management.

JWT Token generator, maybe I will figure this out later. JWT stands for JSON Web token and is used for authentication, I guess it is used for the same reason here, but there is no explanation.

It looks like, that everything went well. But what surprises me here, is the information about sylius 1.10 documentation from the early screenshot. Maybe the script was not updated, because the latest stable release is 1.11.

Jolly good, we are now few steps apart to access the shop for the first time. Now at the point of installing assets there are some information I figured out by chance.

The Documentation mentions that Sylius uses Gulp to build frontend assets by using yarn. Nevertheless gulp seems to die in future.
I received the following information about Sylius 1.12 which is going to be released in few weeks:

* Symfony 6 support — it’s already closer than ever, we should be able to finish it before BETA.1 release
* Support of ApiPlatform 2.7 — hopefully doable before ALPHA.1
* Drop gulp, webpack support — should be finally done before BETA.1

Therefore I crawled through the documentation to found out how to use webpack.
But let’s give it a chance right now and call the command yarn install.

BAM! First error! So I googled the problem, because I could not find the information in the documentation.
The solution: I had node 16 installed, but sylius needs node 14. The next thing I did was installing nvm, selected node 14 and tried yarn install again.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | zsh
nvm install lts/fermium
yarn install
yarn build

But wait, there is still gulp. What now? The information was hidden on this part of the documentation: https://docs.sylius.com/en/latest/cookbook/frontend/webpack.html I followed the steps and installed the webpack. After that I changed scripts of my packages.json file to

"scripts": {
"build": "encore dev",
"build:prod": "encore production",
"watch": "encore dev --watch"
},

So I run yarn build again and everything looks fine, so I tried to start sylius with symfony server:start and tried to access it and received my first HTTP 500.

Why did I got this error? Because I was lazy, I just installed webpack but this was not enough to use it, so I followed the next steps. First of all, if the file ‘config/packages/assets.yaml’ is not created, then just create it and add, what’s written in 2 of the link above:

framework:
assets:
packages:
shop:
json_manifest_path: '%kernel.project_dir%/public/build/shop/manifest.json'
admin:
json_manifest_path: '%kernel.project_dir%/public/build/admin/manifest.json'

and if the webpack_encore.yaml is not created, just do the same and add what’s written in 3.
I build and started sylius again and received the same error. Then I saw a tip at the end of the documentation:

I deleted them and tried everything again, but with no success. I could not find the error, therefore I did merge the two manifest.json files above manually into one manifest.json file in public/build, what I think should be done by default, build and started sylius.

Voíla! Here we are!

What now? First I need therapy … just kidding, I guess I need some Knowledge in PHP for the future. I found out there is no CMS available by default and found a plugin from Bitbag, which I definitely will install.

I also need to figure out how to change style and content easily and in a way that I can update sylius without destroying my design.

If it is a worthy tellable story, I will write it down.

— Cheers

This was my very first medium post, please give me as much as feedback as possible and I hope you enjoyed my ride.

--

--