Skip to content

xDouglas90/php-docker-env-boilerplate

Repository files navigation

PHP Dev Environment in Docker

Boilerplate for PHP development environment by Docker.

Badge Badge Badge Badge Badge

Includes the services:

  • PHP 7.4-fpm
  • Nginx
  • MySQL 5.7
  • Redis

File with updates information, in case you want to know: click here


Prerequisites

The only prerequisites for creating the local development environment are Docker and docker-compose.


Init

Once you have Docker and docker-compose installed and configured, follow these steps:

  1. Clone this repository:
git clone git@github.com:xDouglas90/php-docker-env-boilerplate.git
  1. 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)
    
  2. Now, init the containers:

docker-compose up -d
  1. Confirm that you uploaded everything correctly with docker-compose ps. In the column State all must contain the word up.

  2. Run the following command in the terminal, in the project root folder, to install all Composer packages:

docker-compose exec app composer install

Use

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


Notes

  • 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 your Pull Requests.

About

My PHP development environment boleirplate by Docker.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published