How to Install Symfony Framework in Linux

by Isai Mills
13 minutes read

How to Install Symfony Framework in Linux

Serviceability Image

Symfony is one of the impeccable complete-cluster PHP frameworks, via over 6 hundred thousand originators making swipe advantage of of it proactively. Specifically, it’s made utility of in the breakthrough of polymorphous contemporary websites and internet entreaties, involving Spotify, Dailymotion, and Trivago.

In this tutorial, you’ll uncover how to mount the Symfony frame on your Linux mechanism.

Content
  • Features of Symfony
  • Pre-essentials for Placing Symfony
  • Placing Symfony on Linux
  • Install Symfony CLI
  • Install Composer
  • Create Your First Net Feat
  • Debug your Net Feat

Features of Symfony

Symfony frame enables you to hone multiplex websites, internet entreaties, and microservices on your Linux mechanism promptly by launching an proceeded tool kit and polymorphous reusable parts. Here are some of the impeccable features of Symfony:

  • Responsive resource, rapid, flexible, and faultlessly-documented frame
  • A gigantic extraordinary urban of originators, testers, clients, integrators, and a play sully more
  • Operates on the MVC (Model-Perceive-Controller) version
  • Numerous reusable and decoupled Symfony parts
  • Complete-featured database courses
  • Utilizes Composer as its dependency boss
  • Planned catalog frame
  • Flexible URI routing
  • Cache management and pitfall logging
  • Object-Oriented Shows (OOP) layout

Pre-essentials for Placing Symfony

As stipulated earlier, Symfony is a PHP frame, so you should mount PHP and some polymorphous other dependencies on your mechanism in the past installing it.

Firstly, add the PHP repository to the checklist of repositories in your mechanism by running the consequent commands according to your Linux distro:

#debian-based system sudo apt install software-properties-common -y sudo add-apt-repository ppa:ondrej/php   #Fedora-based system sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y sudo dnf install https://rpms.remirepo.net/fedora/remi-release-$(rpm -E %fedora).rpm -y sudo dnf module enable php:remi-7.4 -y
Contain PHP Repository to Linux distro

Next off, update your mechanism repositories and mount PHP 8.2 along via polymorphous other obligatory dependencies:

# Debian-based system sudo apt update sudo apt install php php-cli php-common php-xml libpcre3 git zip unzip -y   # Fedora-based system sudo dnf update sudo dnf install php8.2 php8.2-cli php8.2-common php8.2-xml libpcre3 git zip unzip -y
Install PHP and polymorphous other dependencies

This will mount with one voice the obligatory strategies on your mechanism.

Tab: Instead of PHP 8.2, you can mount any better PHP version.

Last yet not the super least, to mirror the placed PHP version on your mechanism, run the php -v command:

php -v
Php Version
How to Install Symfony Framework in Linux 28

Placing Symfony on Linux

You should mount Symfony CLI and Composer to application the Symfony frame faultlessly.

Install Symfony CLI

To download and mount Symfony, you can application either the wget or curl command:

# Install Symfony via wget wget https://get.symfony.com/cli/installer -O - | bash   # Install Symfony via curl curl -sS https://get.symfony.com/cli/installer | bash
Install Symfony

Next off, add Symfony to your mechanism’s PATH seating variable and apply the variations:

export PATH="$HOME/.symfony5/bin:$PATH" source ~/.bashrc
Create Symfony PATH

This way, Symfony is placed and ensconced appropriately.

Install Composer

Afterward, you should mount Composer, the dependency boss for PHP, which you’ll application while sharpening your vacancies.

For this purpose, first download the Composer installer manuscript and mirror its dependabilities by evaluating upward to the hash:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Then, run the consequent commands to mount Composer and separate its installer manuscript from your mechanism:

php composer-setup.php php -r "unlink('composer-setup.php');"
Composer Installation

Last yet not the super least, you can run the symfony check:req command to make certain that Symfony is with one voice strategy for you to start sharpening your first internet emit:

symfony check:req
Check Requirment

Here, you can observe in the overhanging result that you’re with one voice strategy for the breakthrough.

Create Your First Net Feat

Before building the first internet emit in Symfony, it’s always deliberated a considerable strategy to configure git on your mechanism. For this purpose, run the consequent git commands to configure your git username and e-mail:

git config --global user.email "email_address" git config --global user.name "full_name"
Config Git

To Retain in Psyche: Recovery your e-mail and username in the overhanging commands.

You’re ultimately with one voice ensconced to version your first Symfony internet emit.

For instance, to version a internet emit labelled “mte” you will run the below command:

symfony new --webapp mte
Create internet emit

Singularly, if you yearn to version a microservice or API instead of a internet emit, carry out the consequent command:

symfony new mte

After the provable creation of your chore, navigate to its catalog and start the Symfony server:

cd mte/ symfony server:start
start Symfony internet Internet server

Specifically, you can observe that the internet server is paying focus at http://127.0.0.1:8000. Currently, open your favorite internet web browser and access the server by gleaning in this paying focus address.

Symfony internet emit welcome page

Last yet not the super least, You can start coding the first page of your internet emit. Relaxed coding!

Debug your Net Feat

During the breakthrough of a internet emit, you’ll need polymorphous tools, especially debugging tools, to centralize your experience and performance. Although Symfony bargains some constructed-in debugging tools prefer Profiler, you have the void to incorporate the impeccable debugging contraption via it to receive a custom debugging journey.

Image credit rating: Nimrach Chaudhry. Unanimously variations and screenshots by Nimrah Chaudhry.

Related Posts