On other occasions, we have talked about various PHP frameworks. For example, I taught you how to install Cake and Yii, but today I’ll teach you how to install Symfony which is perhaps one of the most robust.
Symfony PHP is a high-performance framework for developing web applications. So, it is very popular among groups of developers working on medium to large scale projects. In addition, it is one of the best-documented frameworks, with many books that teach you how to use its full potential.
So, let’s install Symfony on Ubuntu 18.04.
1. Install Apache web server
The first step is to install a web server, in this case, I will use Apache because it is easy to install and use.
:~$ sudo apt install apache2
Then, start and enable the service.
:~$ sudo systemctl enable apache2 :~$ sudo systemctl start apache2
And that’s it.
2. Install PHP
Since it is a PHP framework it is obvious that you have to install the PHP language. So let’s go for it.
:~$ sudo apt install php libapache2-mod-php php-mbstring php-xmlrpc php-soap php-gd php-xml php-cli php-zip php-mysql php-curl
Now, restart apache.
:~$ sudo systemctl restart apache2
3. Install MariaDB
If you are going to develop with a framework, it is necessary to have a database manager, so install MariaDB.
:~$ sudo apt install mariadb-server
Then, enable and start the service.
:~$ sudo systemctl enable mariadb :~$ sudo systemctl start mariadb
Now, set a root password for MariaDB. You can do it using the mysql_secure_installtion
script.
:~$ sudo mysql_secure_installation
There you can configure other options, however, I leave it to your discretion the answers as for this tutorial are not decisive.
4. Install Symfony PHP
To install Symfony 4, you must first install Composer. Composer is a dependency manager for PHP.
:~$ wget https://getcomposer.org/installer :~$ php installer
As you can see, after an initial connection error, composer is installed properly.
Next, make Composer a global command.
:~$ sudo mv composer.phar /usr/local/bin/composer
:~$ sudo chmod +x /usr/local/bin/composer
5. Create a new project
Now it’s time to create a new Symfony project. It’s very simple.
:~$ composer create-project symfony/website-skeleton example
Obviously, put the name of the project you want.
Then, serve the project.
:~$ cd example :~$ php bin/console server:run
Finally, open the web browser an go to http://IP_SERVER:8000
. Or you can specify the IP and the port. It is useful if you are using a VM.
And that’s it.
Conclusion
While it is true that Symfony is a framework not so easy to learn, its installation on Ubuntu 18.04 is quite simple. All that’s left is for you to develop brilliant applications with it.
Please share this post with your friends.
perfect thanks a lot.
Thanks. Do not forget to ahre the post to help many people more.