Install Symfony PHP Framework on AlmaLinux 8

In this guide, we intend to show you to Install Symfony PHP Framework on AlmaLinux 8.

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.

Symfony has a huge amount of functionality and an active community. It has a flexible configuration using YAML, XML, or annotations. Symfony integrates with an independent library and PHP Unit. It is mainly inspired by Ruby on Rails, Django, and Spring web application frameworks. Symfony components are being used by a lot of open-source projects that include Composer, Drupal, and phpBB.

Steps To Install Symfony PHP Framework on AlmaLinux 8

To complete this guide, you need some requirements.

Requirements

First, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with AlmaLinux 8.

Then, you must have PHP 8.1 or higher version installed on your server. For this purpose, you can follow this guide on Installing PHP 8.2 on AlmaLinux 8.

Also, you need to have PHP Composer installed on your server. To do this, you can visit this guide on Installing PHP Composer on AlmaLinux 8.

When you are done, follow the steps below.

Set up Symfony PHP Framework on AlmaLinux 8

In this guide, you will learn to download and use the Symfony installer.

Symfony Installer is used to create web applications in the Symfony framework. Now, let’s configure the Symfony installer.

First, create the directory with the command below:

sudo mkdir -p /usr/local/bin

Then, use the curl command to download the Symfony installer script on AlmaLinux 8:

sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony

Next, set the correct permissions for your file:

sudo chmod a+x /usr/local/bin/symfony

Create Symfony Apps with Composer

At this point, you can create Symfony applications using Composer on AlmaLinux 8. Hopefully, you have installed the composer on your machine.

The following command is used to create a project using the composer:

$ composer create-project symfony/framework-standard-edition app_name

Note: If you need to specify a specific version, you can specify it in the above command. Here we create a project named HelloWorld.

$ composer create-project symfony/framework-standard-edition HelloWorld

At this point, you need to switch your project directory with the command below:

cd HelloWorld

Then, use the following command to run your application:

php bin/console server:run

In your output you will see:

Output
[OK] Server listening on http://127.0.0.1:8000

// Quit the server with CONTROL-C.

 Development Server (http://127.0.0.1:8000) started

After executing the above command, open your browser and request the URL http://localhost:8000/. You will see the Symfony welcome screen.

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

Conclusion

At this point, you have learned to Install Symfony PHP Framework on AlmaLinux 8.

Hope you enjoy it.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!