Giter Site home page Giter Site logo

docker-php-dev-env's Introduction

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.

docker-php-dev-env's People

Contributors

jlucki avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.