Sign inSign up

gerardnico/php-dev

By gerardnico

•Updated over 5 years ago

Php in docker in order to be able to set up quickly a dev environment with debugging capability

Image
Developer tools
Web servers
0

449

gerardnico/php-dev repository overview

⁠Php Dev environment in Docker

Docker Build Status

⁠About

This is a docker image that I use as development environment with:

  • Php

  • Apache:

    • Mod Rewrite enabled
    • Cors enabled

⁠Debug Configuration

The important configuration is the host in the php.ini⁠. This configuration is where xdebug should send its data.

The value is now set to the docker host

# xdebug version 2 (image 7.2)
xdebug.remote_host=host.docker.internal
# xdebug version 3 (image 7.4)
xdebug.client_host=host.docker.internal

If your docker setup uses another name or ip to contact your ide (laptop), you need to change this configuration and restart the container.

You can test the connection from the container to your laptop with the following command

docker exec -it containerName bash
apt-get install -y nmap
nmap -Pn -p T:9000 host.docker.internal

The output should show that the port is open.

⁠Usage on Windows

A whole article is available here: PHP - (Debug|Debugger) with Xdebug in Docker⁠

Short version:

  • Install Docker. See this article⁠ for Windows 10 or this one⁠ for Windows 7
  • Create a container by mounting your whole application to /var/www/html. For instance:
REM in a DOS Shell
cd YourApplication
docker run ^
    --name myapp ^
    -d ^
    -p 80:80 ^
    -v %cd%:/var/www/html ^
    gerardnico/php-dev:7.4
# in Powershell
cd YourApplication
docker run `
    --name myapp `
    -d `
    -p 80:80 `
    -v ${pwd}:/var/www/html `
    gerardnico/php-dev:7.2

⁠FYI

⁠Get a bash shell
docker exec -ti $(CONTAINER) /bin/bash

Tag summary

Content type

Image

Digest

Size

202.4 MB

Last updated

over 6 years ago

docker pull gerardnico/php-dev