Install Symfony PHP Framework on Ubuntu 20.04

In this article, we want to teach you to Install Symfony PHP Framework on Ubuntu 20.04.

Symfony is an open-source PHP web application framework, designed for developers who need a simple and elegant toolkit to create full-featured web applications.

Due to its flexibility and active community, it has always been meeting the latest trends.

Being available under an open-source license, Symfony can be adjusted to the specific needs of every single developer by adding single-handedly any required module of their own.

Steps To Install Symfony PHP Framework on Ubuntu 20.04

Before you start to install Symfony on Ubuntu 20.04, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with Ubuntu 20.04.

Now follow the steps below to install Symfony on Ubuntu 20.04.

Install Symfony CLI on Ubuntu 20.04

First, you need to update your local package index with the following command:

sudo apt update

As we mentioned, Symfony is a PHP web application framework. So you need to install PHP 7.2 or higher and its required packages on Ubuntu 20.04 with the following command:

sudo apt install php php-json php-ctype php-curl php-mbstring php-xml php-zip php-tokenizer php-tokenizer libpcre3 --no-install-recommends

Also, you need to install GIT, Zip, and Unzip on your server with the command below:

sudo apt install git zip unzip

Now you can use the wget command to download and install Symfony CLI on Ubuntu 20.04:

wget https://get.symfony.com/cli/installer -O - | bash
Output
The Symfony CLI v4.28.1 was installed successfully!

Configure Symfony Ubuntu 20.04

When your installation is completed, you need to add the Symfony installation path to the PATH user using the following command:

export PATH="$HOME/.symfony/bin:$PATH".

Now you can apply the changes by running the following command:

source ~/.bashrc

At this point, you can use the following commands to configure your email and username in Git:

git config --global user.email "Your_Email_Address"
git config --global user.name "Your_User_Name"

Test Symfony PHP framework

Now you can create a new project to test your Symfony PHP framework:

symfony new example --full

When you are done, switch to your project directory:

cd example

Start the local webserver with the Symfony command on Ubuntu 20.04:

symfony server:start
Output
[OK] Web server listening
The Web server is using PHP CLI 7.4.3
http://127.0.0.1:8000

Finally, you can check your Symfony project by going to the following address:

http://your-server-ip:8000/

You will see the Symfony welcome screen.

To exit from the Symfony PHP framework, you can press Ctrl + C.

For more information, you can visit the Symfony Documentation page.

Conclusion

At this point, you learn to Install Symfony PHP Framework on Ubuntu 20.04. Also, you learn basic usage of it by creating a new project.

Hope you enjoy it.

You may be like these articles:

Install Symfony PHP Framework on Centos 7

Install Symfony PHP Framework on Ubuntu 22.04

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!