First we will assume you have completed some server creation/setup, like described in the article below
Then after that, we must ensure we have Composer installed, you can see how to do that in the article below
If you have met those pre-requisites, we are ready to being focusing on Symfony itself. For a while now Symfony has moved away from cloning a repository and then installing the framework, like we used to do, and most other frameworks still do. Symfony now provides a CLI tool to manage and setup projects interactively.
Let’s install the Symfony CLI tool.
curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash
sudo apt install symfony-cli
From: https://symfony.com/download
The first command should result in something like
And the second installs the Symfony CLI from the APT repositories.
Optionally, you can now verify your system requirements for Symfony
symfony check:requirements
Which would give you something like
After this you are ready to start a Symfony Project. For this example we are going to create a web app
. This will allow us to show a webpage after completion, but Symfony is excellent for many reasons besides websites, think more like (RESTful) API’s or Micro Services.
symfony new my_project_directory --version="7.0.*" --webapp
We used my-example
as our project name / directory.
If you get the screen below, that is just because you have yet to configure GIT for your user on that machine. Follow the two (git config
) instructions, then you have to remove the directory that was created, before you can re-run the same command as before.
All we really need is a Virtual Host to be configured so we can see the results.
sudo nano /etc/apache2/sites-available/symfony-example.conf
After Nano (or your editor of choice) opens, you can enter the following Virtual Host, just make sure to change your domain name, or comment out the ServerName
line (place a #
in front of it)
<VirtualHost *:80>
ServerName my.example.com
DocumentRoot /var/www/example/public/
<Directory /var/www/example/public>
Options FollowSymLinks
AllowOverride None
FallbackResource /index.php
Require all granted
</Directory>
</VirtualHost>
For Nano you can use CTRL+o (not zero), to save the file, and CTRL+x to exit.
sudo a2ensite symfony-example
sudo service apache2 reload
Then we can visit our site and see
Show us we have a working Web Application, enjoy and see you next time!
Leave a Reply