Introduction
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.
Prerequisites
- Deploy a Linux server instance with the version of PHP greater than or equal to PHP 5.4. The Vultr LEMP application qualifies.
- Log in as a non-root user that has sudo privileges. You can create such a user in accordance with this article.
Step 1: Download the Symfony installer
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.
Step 2: Create the Symfony application
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
Step 3: Run and verify the Symfony application
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
Visit http://127.0.0.1:8000/
from Lynx:
lynx http://127.0.0.1:8000/
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/cache
and ~/my_project/var/logs
directories. Visit the Symfony website for more details.
Step 4: Check Symfony application configuration
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:
lynx http://localhost:8000/config.php
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:
php -v
-
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:
sudo reboot
-
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.
Want to contribute?
You could earn up to $300 by adding new articles
Suggest an update
Request an article