Skip to content

A simple web development environment using Docker with NGINX, PHP, MySQL and Xdebug.

Notifications You must be signed in to change notification settings

jmayermsi/docker-php-dev-env

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker PHP Development Environment

This repository allows you to quickly get a development environment up and running using Docker, including a MySQL database and some debugging tools.

This environment includes the latest versions of the following software:

  • nginx:alpine
  • php:8.0-fpm
  • mysql:latest
  • xdebug

Prerequisites

  • Docker (https://www.docker.com/products/docker-desktop)
  • Tested on macOS 10.15 (Catalina) and Windows 10 Version 10.0.18362
  • Windows 10 requires Docker File Sharing with the C drive to be enabled in the Docker settings, restart may be required after enabling sharing

Running the Container

  1. Using composer: composer create-project jlucki/docker-php-dev-env <project name> or download the files from this repo and copy them to your project directory
  2. Run docker-compose up from the project directory
  3. Visit localhost in your browser

Setting up Xdebug in Your IDE

The following instructions are for PHPStorm.

  1. Click on Run > Edit Configurations
  2. Click the + and add a new PHP Remote Debug configuration
  3. Give the configuration a name
  4. Tick Filter debug connection by IDE key
  5. Add PHPSTORM in the session id
  6. Click the ... next to Server
  7. Click the + to add a new server
  8. Give the server a name, and set the host to 127.0.0.1
  9. Tick Use path mappings
  10. Open the Project files drop down
  11. Find the public folder, and under Absolute path on the server add /code/public
  12. Hit Apply and OK until you've returned to the IDE
  13. Click the Start Listening for PHP Debug Connections icon
  14. Set a breakpoint in your code
  15. Refresh the page in your browser
  16. Accept Incoming Connection From Xdebug
  17. Happy debugging!

See https://xdebug.org/docs/remote for how to enable xdebug sessions.

Additional Notes

For database connections, use mysql as the hostname. If you would like a different hostname, change the service name in the docker-compose.yml file.

About

A simple web development environment using Docker with NGINX, PHP, MySQL and Xdebug.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dockerfile 89.8%
  • PHP 10.2%