Install Symfony in Fedora
Tutorial on how to install PHP Symfony Framework on Fedora.
In this short tutorial, we will install Symfony and its basic requirements on our Fedora System. So open your terminal and let's begin.
NOTE: Make sure your user has superuser access.
1 - Install PHP
First, we need to have PHP installed in our system. In your terminal, paste the following command to install php-cli
:
sudo dnf install -y php-cli
Let's verify that PHP is installed in our system:
php --version
The output should be similar to the following screenshot:
In this case, we have PHP version 8.1 with Parch 18 installed. Now that we have PHP installed, let's install Composer
.
2 - Install Composer
What is PHP Composer`?: Composer is the package manager of PHP. It manages all the dependencies of a project for us so that we can focus on our project without worrying.
To install Composer, copy and paste the following command in your terminal.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') {
echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
This shell script below does 4 things:
Download the
composer-setup.php
script.Verify the
hash
script of the script.Run the
composer-setup.php
script.Delete the
composer-setup.php
script from the current directory.
Running the command ls -la
, you can observe that the current directory has only 1 file left called composer.phar
.
composer.phar
is the executable of the php package manager called composer.
Now let's move the composer executable to our /usr/local
to access it globally, and let add /usr/local
folder in our $PATH
environment variable:
sudo mv composer.phar /usr/local/composer
echo "PATH=$PATH:/usr/local/" >> ~/.bashrc
Now that's done, let's execute our .bashrc
file to make the changes immediately available:
source ~/.bashrc
Check if Composer is installed in your system with the following command:
composer --version
The result should be similar to the following screenshot the following:
3 - Install Symfony Framework
When you have installed in your Fedora system PHP and Composer, you can now install Symfony Framework.
From Oficial Symfony Website: In your terminal, copy and paste the following command (either use wget or curl):
- Install Symfony with wget:
wget https://get.symfony.com/cli/installer -O - | bash
- Install Symfony with curl:
curl -sS https://get.symfony.com/cli/installer | bash
Either way should show us the following result:
Now lets add symfony to our $PATH environment variable:
echo 'PATH="$HOME/.symfony5/bin:$PATH"' >> ~/.bashrc
And execute the ~/.bashrc
file to make the changes immediately available:
source ~/.bashrc
Lastly, lets check if Symfony is installed in our system:
symfony check:requirements
Conclusion
In this short tutorial, we have installed PHP, Composer and Symfony. In the next tutorials of this series, we will go deeper into how to use Symfony for web projects.
Got some problems during the installation?
Feel free to leave a comment down below if you encounter any problems. I will try to help you resolve it ๐.