Public | Automated Build

Last pushed: 33 minutes ago
Short Description
Yet another PHP Docker image for development (based on Alpìne Linux for minimal size)
Full Description

PHP development Docker image

Yet another PHP Docker image for development (based on Alpine Linux for minimal size)

Focused on library/package development

Bundled with:

Available tags

Environment variables


  • Type: int
  • Default: 0

Disable xDebug by setting a non zero value


  • Type: string
  • Default: auto discovered host's ip

Remote server (host) IP to connect to


  • Type: integer
  • Default: 9000

Remote server port to connect to, IDE should be listening on this port


  • Type: integer
  • Default: 0
  • Not recommended

Auto start remote debugging.


  • Type: string
  • Default: not set
  • Not recommended

Fixed remote session identifier.

Note: escape the string for use in sed


  • Type: string
  • Default: not set

Protocol format to integrate IDEs with stack trace file links. You can provide your custom format or use one of the supported formats: "phpstorm", "idea", "sublime", "textmate", "emacs" or "macvim"

Note: if you use your custom format remember to escape the string for use in sed



The default working directory. You should mount your project root path in this volume.


Logging volume for PHP and PHP-FPM logs and xDebug log, profile and trace files.


Getting the image

docker pull juliangut/phpdev:latest
docker pull juliangut/phpdev:fpm-latest

Running a container

docker run -it -v `pwd`:/app juliangut/phpdev:latest

Running built-in server in a container

docker run -d -p 8080:8080 -v `pwd`:/app juliangut/phpdev:latest php -S -t /app/public

Access running server on http://localhost:8080

With Docker Compose
  image: juliangut/phpdev:latest
    - "8080:8080"
    - .:/app
  command: "php -S -t /app/public"
docker-compose up

Running composer command in a container

docker run -v `pwd`:/app juliangut/phpdev:latest composer [command]

Accessing a running container

docker exec -it [container_id] /bin/sh

Using xDebug

It is not recommended to have a fixed remote session identifier and an auto-started remote session using "XDEBUG_IDE_KEY" and "XDEBUG_REMOTE_AUTOSTART" respectively.

The preferred way of starting a remote debug session is by setting remote session identifier dynamically by one of the following means

  • On browser by setting "XDEBUG_SESSION" cookie with the session identifier as its value.
  • On HTTP request (cURL) by adding "XDEBUG_SESSION_START" parameter to the URI or as a POST parameter. eg: curl -X POST -F "XDEBUG_SESSION_START=PHPSTORM" http://example.local
xDebug profiler

To activate the profiler set "XDEBUG_PROFILE" cookie. Profile cachegrind.out.* files will be saved into /var/log/php directory

xDebug trace

To activate the trace set "XDEBUG_TRACE" cookie. Trace *.xt files will be saved into /var/log/php directory

Browser support

There are browser plugins/extensions to toggle debug cookies easily

Debugging with PHPStorm

Review xDebug configuration

  • Port must be the same previously defined in XDEBUG_REMOTE_PORT
Create a server

  • Server name will be used later so make it relevant
  • Host and port must be the same set in built-in server
  • Map your project root to container location (/app)
Start listening for xDebug connections

Click the phone icon to start listening

Start the container

Setting PHP_IDE_CONFIG environment variable to the server name you defined earlier

docker run -d -p 8080:8080 -e PHP_IDE_CONFIG="severName=Test" -e XDEBUG_FILE_LINK_FORMAT=phpstorm -v `pwd`:/app juliangut/phpdev:latest php -S -t /app/public
Using Docker Compose
  image: juliangut/phpdev:latest
    - "8080:8080"
    PHP_IDE_CONFIG: "severName=Test"
    - .:/app
  command: "php -S -t /app/public"
docker-compose up

Extending the image

The image comes with just the minimum PHP extensions, you most probably will need more.

FROM juliangut/phpdev:latest

RUN docker-php-ext-install \
    pdo_mysql \
  && pecl install \
    mongodb \
    redis \
  && docker-php-ext-enable \
    mongodb \
    redis \

RUN composer global require phpunit/phpunit


See file LICENSE included with the source code for a copy of the license terms.

Docker Pull Command
Source Repository

Comments (0)