Symfony is one of the most popular PHP frameworks that can be used to develop your own applications easily and rapidly. Featuring an assortment of decoupled and reusable components and a huge community of developers, Symfony has attracted many open-source community members.
In this article, I will show you how to install and use Symfony 3.0.0 for application development on a Vultr LEMP VPS.
The officially recommended method to install Symfony is to use the Symfony installer.
Log in from an SSH terminal, input:
sudo curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony sudo chmod a+x /usr/local/bin/symfony
Now you can use the
symfony command from your shell.
Create a new application with Symfony:
symfony new my_project
This command will create a directory called
my_project in your home directory to host all of your application files.
If you want to specify the version of Symfony, append the version number to the command mentioned above, like:
symfony new my_project 2.6 symfony new my_project 2.6.5 symfony new my_project 2.7.0-RC1 symfony new my_project lts
Execute the following commands to start the Symfony application:
cd my_project/ php bin/console server:run
If the operation was successful, you will see the prompt
[OK] Server running on http://127.0.0.1:8000 appear on your screen. You can verify the result by accessing the URL
http://127.0.0.1:8000/ from a web browser.
Keep the command running in the current SSH terminal. Open another SSH terminal and download a text browser called Lynx:
sudo yum install -y lynx
http://127.0.0.1:8000/ from Lynx:
You will see the welcome page of Symfony: "Welcome to Symfony 3.0.0". Then press Shift + Q to quit Lynx.
If by any chance you see a blank page or an error page instead of the welcome page, you can try to fix the problem by reconfiguring the permissions on the
~/my_project/var/logs directories. Visit the Symfony website for more details.
You can also use a server configuration tester to check if your environment is ready for using Symfony. Access the following URL while your Symfony application is running:
In the Vultr LNMP environment, the server configuration tester will recommend us to install and enable the intl extension (used for validators) for a better Symfony experience. Here is the solution:
Press the down arrow once, then press Shift + Q to quit the Lynx browser.
Check the version of PHP on the server:
Query and install the intl extension of the same version (my server was running PHP 5.5):
yum list php*intl sudo yum install php55u-intl.x86_64
Reboot the system:
Log in and check the Symfony application configuration again, you will find that the problem has been solved ("All checks passed successfully.").
Congratulations! You have setup a Symfony application.
Please note that the content in this article is suitable for a development environment only; you'll need to do more configuration for a production environment. For further reading, visit the official Symfony website.