Jobeet Day 1: Starting up the Project
Today we will setup the development environment, install Symfony 4.2 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 Docker with nginx and PHP images from Docker Hub. To check the minimum requirements for running Symfony 4.2 you can access this link.
After you install Docker and Docker Compose, create a new folder named
jobeet, copy the archive into the folder and decompress it.
It is initial configuration for generic PHP project, which was generated by service phpdocker.io.
It includes PHP 7.2, MySQL 5.7 and nginx. To start containers just run next command:
docker-compose up -d
What we did here:
- we called
docker-composethat wraps the functionality of Docker and does working with Docker easier
- this command reads configuration from
docker-compose.ymlfrom folder where command is run
upmeans start and run our entire application
-dmeans detached mode. Command will run containers in the background and console will be free to use for next commands.
After several minutes containers will be running and you can check it with next command:
The result should be the same:
Name Command State Ports ------------------------------------------------------------------------------- jobeet-mysql docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp jobeet-php-fpm /bin/sh -c /usr/bin/php-fpm Up 9000/tcp jobeet-webserver nginx -g daemon off; Up 0.0.0.0:80->80/tcp
Congratulations! Now you have prepared environment for Jobeet project.
Download and install Symfony 4.2
To create our Symfony project we will use method described in official documentation. First of all, enter PHP container:
docker-compose exec php-fpm bash
execcommand is used to run commands in container
php-fpmis the name of the container (line 27 in
bashexecutes bash in the container
Now you are in php container. Run
php -v to check that php exists and the version is
After that create Symfony project in
tmp (temporary) folder, copy it to your project folder, exit from container and change permission of files to be able to edit them from your IDE:
composer create-project symfony/website-skeleton:4.2.* /tmp/jobeet/ cp -aR /tmp/jobeet/. . exit; sudo chown -R $USER:$USER .
We install into
tmp directory and copy then to proper one, because
create-project command requires target folder to be empty, but in project’s folder we already have docker files.
Test the Symfony installation
Now open your web browser and enter the http://127.0.0.1 URL. You should see error
No route found for "GET /" but it’s OK. You don’t have any routes created yet.
Symfony 4 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:
Note: don’t forget first to enter in PHP container if you are not in:
docker-compose exec php-fpm bashand to execute this command from PHP container
Symfony 4 has different environments. If you look in the project’s directory, you will see file
.env with variable
prod stands for production environment and
dev 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://127.0.0.1 in your browser (note the bottom debug toolbar).
That’s all for today. You can find the code from this day here: https://github.com/gregurco/jobeet/tree/day1. See you on the next day of this tutorial where we will talk about what exactly the Jobeet site will be about!
Continue this tutorial here: Jobeet Day 2: The Project
Main page is available here: Symfony 4.2 Jobeet Tutorial