Boilerplate for PHP development environment by Docker.
Includes the services:
- PHP 7.4-fpm
- Nginx
- MySQL 5.7
- Redis
File with updates information, in case you want to know: click here
The only prerequisites for creating the local development environment are Docker and docker-compose.
Once you have Docker and docker-compose installed and configured, follow these steps:
- Clone this repository:
git clone git@github.com:xDouglas90/php-docker-env-boilerplate.git
-
Navigate to the repo folder and copy
.env-example
file and rename to.env
.2.1 Open
.env
file and add the following values to the variables:APP_NAME=your-app-name DB_DATABASE=your-database-name DB_USERNAME=your-mysql-username or root DB_PASSWORD=your-mysql-user-password or root DB_LOCAL_PORT=3306 (set a custom port if you need) NGINX_LOCAL_PORT=80 (set a custom port if you need) REDIS_PORT=6379 (set a custom port if you need)
-
Now, init the containers:
docker-compose up -d
-
Confirm that you uploaded everything correctly with
docker-compose ps
. In the columnState
all must contain the wordup
. -
Run the following command in the terminal, in the project root folder, to install all Composer packages:
docker-compose exec app composer install
Open the browser and add the following link http://localhost/.
CAUTION: If you have added any custom ports in the NGINX_PORT=xxxx
environment variable, you must then open the link localhost:xxxx.
If everything is ok, you will see the following content on the rendered page: MySQL version:5.7.37
-
If you have any questions or problems, feel free to call me. My contacts are in my profile README.
-
In the not too distant future, I intend to configure Laravel to also run in a development environment.
-
In the future (which I hope is not too far away), I intend to configure it to run in test and production environments.
-
Last but not least, feel free to also
Fork
this project and fix/add what you think is missing from it. It will be a pleasure to accept yourPull Requests
.