Setting Up the BackEnd 
After reading the Technologies used in backend and Setting up the FrontEnd, We are ready to continue the setup, build and deployment process of the SimpList's BackEnd.
We obviously need PHP to be installed, after that we have two options when it comes to backend, manual and docker deployment.
Docker Method (Recommended) 
WARNING
This step requires correct setup of Environment Variables, otherwise you will face errors.
Method 1: Deploy On Render.com (Recommended) 
Our recommended method of deploying backend using docker, is to deploy it at Render.com, You need to login to your account and create a new Web Service project, then you will connect your Github repository containing the backend or you can use the original public repository of SimpList.
Afterwards, you will have to click on Advanced and set the Docker Build Context Directory to backend directory, and you must set all the Environment Variables needed for backend. Then you can click on Create Web Service and enjoy the deployment as it proceeds.
Method 2: Deploy On Other Infrastructures 
Just like previous method, you can follow the same process on any containerized infrastructure.
Method 3: Build Image from the Dockerfile 
cd backend
$ sudo docker buildx build . -t erfanmola/simplist
$ sudo docker run -it erfanmola/simplistcd backend
$ sudo docker buildx build . -t erfanmola/simplist
$ sudo docker run -it erfanmola/simplistMethod 4: Pull Image from DockerHub 
$ sudo docker pull erfanmola/simplist
$ sudo docker run -it erfanmola/simplist$ sudo docker pull erfanmola/simplist
$ sudo docker run -it erfanmola/simplistManual Method 
In this method, we have to change our Working Directory to backend folder, since it's the folder containing our backend code:
cd backendcd backendInstalling OpenSwoole 
Open Swoole is a high-performance network framework based on an event-driven, asynchronous, non-blocking I/O coroutine programming model for PHP.
OpenSwoole is a PHP Extension, which means you will need a bit more effort to install it manually than a library needs. This is a dedicated guide of installing OpenSwoole, but we are going to summarize it.
Method 1: Install using PECL 
In this method, you need to satisfy the build dependencies of OpenSwoole ourselves, then we can retreive and build it using PECL:
$ sudo pecl install openswoole$ sudo pecl install openswooleMethod 2: Install using OS Package Manager (Ubuntu for example) 
apt update
apt install -y software-properties-common && add-apt-repository ppa:ondrej/php -y
apt install -y software-properties-common && add-apt-repository ppa:openswoole/ppa -y
apt install -y php8.2-openswooleapt update
apt install -y software-properties-common && add-apt-repository ppa:ondrej/php -y
apt install -y software-properties-common && add-apt-repository ppa:openswoole/ppa -y
apt install -y php8.2-openswooleMethod 3: Install using Docker 
docker pull openswoole/swooledocker pull openswoole/swooleINFO
By installing OpenSwoole using Docker, it's not natively installed on your system, so you will need some Docker basic knowledge to use it. You can read more here
Installing Dependencies 
At this step, we need to install our project's dependencies. We use Composer as our package manager.
composer installcomposer installServing the project 
You can serve the project by running the server.php file:
php server.phpphp server.phpWARNING
This step requires correct setup of Environment Variables, otherwise you will face errors.
INFO
The server provided by OpenSwoole HTTP Server keeps running in the background, unlike the usual expectation from a php file.php command. You can start it using a process manager like Supervisor or fork it and pipe it's stdout and stderr to /dev/null.