Symfony 2.8 Jobeet Day 1: Starting up the Project

Today we will setup the development environment, install Symfony 2.8 and display a page of the application in the web browser. First of all, we need to have a friendly working environment for web development. We will use Vagrant and VirtualBox with the latest Ubuntu image from here: To check the minimum requirements for running Symfony 2.8 you can access this link:

Vagrant virtual machine setup

After you download and install Vagrant and VirtualBox, create a new folder named jobeet and run following vagrant command in it:

vagrant init ubuntu/xenial64

This will create a config fine named Vagrantfile that we need to edit. Open it and uncomment the following line: "private_network", ip: ""

Now run vagrant up to create a new virtual machine and install the Ubuntu 16.04 LTS image in it. When it’s done, you can (and you should, in order to follow this tutorial) ssh into it using the vagrant ssh command.

Now let’s install the needed software for our web server:

sudo apt-get update
sudo apt-get install -y php apache2 libapache2-mod-php7.0 mysql-server php-mysql php-intl git git-core curl php-curl php-xml composer zip unzip php-zip

Download and install Symfony 2.8

To create our Symfony project we need first to download and install the Symfony Installer with the following commands:

sudo mkdir -p /usr/local/bin
sudo curl -LsS -o /usr/local/bin/symfony
sudo chmod a+x /usr/local/bin/symfony

Now, create the project (make sure you are in the /vagrant folder on your virtual machine):

cd /vagrant
symfony new jobeet 2.8

You can check if you meet the Symfony requirements by running:

php jobeet/app/check.php

Here’s what I got:

To solve the date.timezone error, edit the /etc/php/7.0/cli/php.ini file, search for the ;date.timezone = and change it to date.timezone = ‘Europe/Bucharest’ (use your own timezone and be sure to uncomment the line). Now the check should look like this:

Web Server Configuration

A good web practice is to put under the web root directory only the files that need to be accessed by a web browser, like stylesheets, JavaScripts and images. By default, it’s recommended to store these files under the web/ sub-directory of a symfony project.

To configure Apache for your new project, edit the /etc/apache2/sites-enabled/000-default.conf configuration file and change it to the following:

<VirtualHost *:80>
ServerName jobeet.local
DocumentRoot /vagrant/jobeet/web
DirectoryIndex app.php
ErrorLog /var/log/apache2/jobeet-error.log
CustomLog /var/log/apache2/jobeet-access.log combined
<Directory "/vagrant/jobeet/web">
AllowOverride All
Allow from All
Require all granted

You will also need to edit the /etc/apache2/envvars file to set the apache2 user to be the same as your CLI user (ubuntu in our case). This is because Symfony needs to be able to write to the app/cache and app/logs folders both when running from the browser and from the command line. You can read more details about this here:

export APACHE_RUN_USER=ubuntu
export APACHE_RUN_GROUP=ubuntu

Now enable the rewrite module and restart apache:

sudo a2enmod rewrite
sudo service apache2 restart

The domain name jobeet.local used in the Apache configuration has to be declared locally. If you run a Linux system, it has to be done in the /etc/hosts file. If you run Windows, this file is located in the C:\WINDOWS\system32\drivers\etc\ directory. Add in the following line on your host machine, not in the virtual machine: jobeet.local

Test the Symfony Installation

There is one more thing tot do before we can see our project running. We need to use composer to install all the dependencies (run from the /vagrant/jobeet folder):

composer install

Now open your web browser and enter thehttp://jobeet.local URL. You should see something like this:

Symfony console

Symfony 2 comes with the console component tool that you will use for different tasks. To see a list of things it can do for you type at the command prompt:

php app/console list

The Environments

Symfony 2 has different environments. If you look in the project’s web directory, you will see two php files: app.php and app_dev.php. These files are called front controllers; all requests to the application are made through them. The app.php file is for production environment and app_dev.php is used by web developers when they work on the application in the development environment. The development environment will prove very handy because it will show you all the errors and warnings and the Web Debug Toolbar — the developer’s best friend. Check the development environment by accessing http://jobeet.local/app_dev.php in your browser (note the bottom debug toolbar).

If you get the You are not allowed to access this file. Check app_dev.php for more information. error, edit the app_dev.php file and change the condition or comment the lines that restrict you to access the project.

That’s all for today. You can find the code from this day here: See you on the next day of this tutorial when we will talk about what exactly the Jobeet website will be about!

Next Steps

Continue this tutorial here: Symfony 2.8 Jobeet Day 2: The Project

About the Author

Passionate about web & mobile development. Doing this at IntelligentBee for the last 5 years. If you are looking for custom web and mobile app development, please contact us here and let’s have a talk.