One of the most widely used PHP frameworks, Symfony, makes it simple and quick to create your own applications. With a large developer community and a variety of decoupled and reusable components, Symfony has drawn a lot of interest from the open-source community.
I’ll walk you through the process of installing and configuring Symfony 3.0.0 for AKLWEB HOST LEMP VPS application development in this post.
- Install a Linux server instance that has PHP upgraded to at least PHP 5.4. The application for Vultr LEMP is eligible.
- Use sudo rights to log in as a non-root user.
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.