Setting up Symfony 3 can be a little headache on windows, and this is the reason why we decided to create this tutorial so you can always come back to the page and follow everything each time you set this up on a new machine.
Make sure to bookmark this page as you will use it a lot during your Symfony learning period.
Let's go straight to the point.
1 - Download Xampp
You can choose the latest version for your windows 10 operating system.
2 - Edit Windows Variables
Edit your windows variables, this tells windows where your PHP and MYSQL paths are located.
In the windows search, type "control", click on the "control panel" icon and click on "Edit the system environment variables". By setting this up, you will be able to run commands anywhere in your cmd control panel.
Go to the bottom of the popup and click on "Environment variables".
Follow the images on this page and add these 2 lines to the paths:
Click on "New" and add them.
3 - Setup Your Vhosts
A virtual host is a kind of routing that tells your computer that a specific domain is linked to a precise folder locally.
It also tells the computer the port being used and the name of the domain.
The reason you need notepad++ is because you may need admin rights to certain files and notepad++ makes it super easy to sort this out for us.
Type this in your windows 10 search bar:
Open it with notepad++
On my windows machine, unfortunately, the port 80 is causing xampp not to start, so in my case, I will be using the port 8080. I believe this is due to skype being installed on my computer.
If you can start xampp and apache turns "green" then your port 80 is fine, otherwise, setup in xampp the port 8080 like this:
Also also, by clicking on the "config" button next ot the apache service, you will have access to the apache httpd.conf file, open it and change this line:
Coming back to the httpd-vhosts.conf
Make sure you have these 2 settings added:
The document root will be the path of your future symfony app.
Change "myfirstapp" to anything you like but make sure that when you will create your symfony app, this name matches the installation folder.
4 - Setting you your local hosts file.
This will tell windows that when you type "myfirstapp.com" it should not go on the web to look for the domain name but instead look on the local server(xampp in your case).
Type this in your windows search bar:
Open it with Notepad++, you may receive a warning saying that you need to have admin rights to save the file, if this is the case click on "This file is protected use the administrator mode..." and the file will reopen with admin rights.
Add this to the file:
5 - Download a certificate for the installation of symfony
Symfony download is secured and you will need a certificate for the download
Place this .pem file here(create the ssl folder):
Go to your php.ini file and add this line to it:
curl.cainfo = "C:/xampp/ssl/cacert.pem"
If you do not know how to access your php.ini file, simply check this image:
6 - Download symfony.phar and add it here:
via this url:
Remember, do not place symfony.phar in your project file but outside(in the htdocs directory).
7 - Open a command prompt(cmd) and type this:
Go to this directory
And now type:
php symfony.phar new myfirstapp
This command will create a new folder called "myfirstapp" with all the require symfony files. On some machines, the download of symfony will take time, be patient as there are a lot of dependencies
7 - Install composer:
After the installation, open a command prompt and type:
8 - Restart apache from xampp and you may also need to restart your pc for everything to work properly.
9 - When the pc reboots, starts xampp and apache, make sure it is "green".
Go to your browser and type:
myfirstapp.com:8080/app_dev.php (if you are using the port 8080)
if this does not work, type:
You should now see a page like this one:
If you loved this life-saving tutorial, please leave us a comment below, it takes time to create this type of step by step and comments are some kind of rewards for us.
We love helping others to achieve their goals!