-
Notifications
You must be signed in to change notification settings - Fork 9
Generate a Laravel project
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.
In order to generate your docker-compose you need to open your favorite web browser, go to https://okty.io/ and press "Start" !
A laravel 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
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
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
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
The first step is to go search on the laravel documentation and check what are the prerequisites
Luckily, most of the prerequisites are already satisfied by default !
The only php extension we have to add is PDO_Mysql.
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" and add it.
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.
That's all for this container ! Let's save and go on with 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 Laravel application, this folder is named "public"
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
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 !
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 --prefer-dist laravel/laravel laravel
docker-compose exec php cp -r laravel/. .
docker-compose exec php rm -rf laravel
Your project is running !
You may go to the next step
Open a terminal and navigate to your project folder.
Run : docker-compose up -d
Of course it is ! Open your favorite web browser and go to http://127.0.0.1:8080/
There is a last step before being able to use all the power provided by laravel, editing the .env file.
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
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 !