Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Generate a Symfony project

Bassin Laurent edited this page Jun 10, 2018 · 3 revisions

This tutorial will show you how to use okty with your project.
These steps may be used with a new project of with an existing one.

Step 1 : Go to Okty.io

In order to generate your docker-compose you need to open your favorite web browser, go to https://okty.io/ and press "Start" !

Okty home page

Step 2 : What do you need ?

A symfony application is a typical php application and need 4 containers to work :

  • Nginx : Handle HTTP requests
  • PHP : Generate your website content and execute all the magic things
  • MySQL : Store your data
  • Adminer : Manage your database (Optional)

We'll start with Mysql and Adminer !
Select Mysql in the list

Step 3 : MySQL

You may leave the first group with default values
In the second configuration group "Connection" you have to specify your authentication data Once all the fields are filled, save your container

Mysql configuration

Step 4 : Adminer

In the list, select adminer.
Adminer is a simple and a small container that doesn't require much configuration
That's why we'll leave all the configuration as is it and save the container

Adminer configuration

Step 5 : PHP

PHP is generally the most complicated container to configure because of all the extensions availables and required depending of the project you're working on.
Don't worry ! Okty is here to help you

Luckily, most of the prerequisites are already satisfied by default ! The only php extension we have to add for symfony is PDO_Mysql and Intl.
You may find information about php extensions and which one is installed on a empty container on this wiki page

Knowing this, we'll select in the php extensions list "PDO Mysql", "Intl" and add them.

The second step is to tell Okty where your code will be.
We recommend to add the docker-compose at the root of your project, default value is just right.

PHP Configuration

That's all for this container ! Let's save and go on with nginx.

Step 6 : Nginx

Finally, the last container to configure before being able to run your project.
Select nginx in the list.

Local path should be the same as specified to php in the previous step.
We recommend to leave it by default at the root of the project

Regarding the web port used on the host machine, 8080 works perfectly but feel free to used whatever value you want that is not already in use by another application.

The max upload size depends of your needs, 2Mo is a default value, feel free to change it.

Nginx needs to know which container will handle PHP, select the id of the php container
(leave empty if you don't need php)

The last field allows us the use modern frameworks which has a dedicated public folder which contains the index.php
In the case of a Symfony 4 application, this folder is named "public"

Nginx configuration

Step 7 : Export

The hardest part is over now !
Just click the export button, download the zip file and unzip your docker-compose. At this point, you may or may not have an existing project.
We'll split this step in two to manage these two situations

Existing project

Copy yout precious docker-compose file, open your project folder and paste the docker-compose at the root of your project.
You may go to the next step !

New project

Create a new folder where your project will be and copy/paste the docker-compose inside it.
Open a terminal and navigate to the project folder.

Run these commands :

docker-compose up -d
docker-compose exec php composer create-project symfony/website-skeleton symfony
docker-compose exec php cp -r symfony/. .
docker-compose exec php rm -rf symfony 

Your project is running !
You may go to the next step

Symfony folder

Step 8 : Free the power of docker !

Open a terminal and navigate to your project folder. Run : docker-compose up -d

Docker compose up

Step 8 : Is it really working ?!

Of course it is ! Open your favorite web browser and go to http://127.0.0.1:8080/

Symfony web view

There is a last step before being able to use all the power provided by symfony, editing the .env file.

env configuration
WARNING : Database host isn't 127.0.0.1, it's the id of the mysql container. In this example : mysql

Note : You may manage your database through adminer using http://127.0.0.1:8081

Step 9 : How should I shutdown my project ?

If you want to stop your database, all you have to do is run one command
docker-compose stop

That's all ! Thanks to Okty, you may start changing the world through your future application !