Install Symfony PHP Framework on Ubuntu 22.04

In this guide from the Linux Tutorials, we want to teach you to Install Symfony PHP Framework on Ubuntu 22.04.

Symfony is a PHP web application framework for MVC applications and it is free software and released under the MIT license.

Symfony aims to speed up the creation and maintenance of web applications and replace repetitive coding tasks. It has a low-performance overhead used with a bytecode cache.

Symfony is aimed at building robust applications in an enterprise context, and aims to give developers full control over the configuration: from the directory structure to the foreign libraries, almost everything can be customized. To match enterprise development guidelines, Symfony is bundled with additional tools to help developers test, debug and document projects.

Install Symfony PHP Framework on Ubuntu 22.04

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 22.04.

Set up Symfony PHP Framework on Ubuntu 22.04

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 22.04.

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

sudo apt update

Then, install PHP and the required packages with the command below:

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 22.04:

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

At this point, 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"

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 22.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

There are a lot of other great frameworks and programming languages out there as well. It depends on what you want to do and what technologies you are familiar with.

Hope you enjoy this article about 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!