cn007b / docker-php

🐳 This repo contains PHP docker images tailored for development purposes (xdebug, composer, php-fpm, nginx, etc).

Home Page:https://hub.docker.com/r/cn007b/php/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP for DEVELOPMENT.

Docker Build Status Docker Automated build Docker Pulls

Create test script with purpose to check docker commands:

echo '<?php var_dump("It works!");' > index.php

CLI:

docker run -it --rm -v $PWD:/app -w /app cn007b/php php index.php

CLI + Xdebug:

docker run -it --rm -v $PWD:/app -w /app -e PHP_IDE_CONFIG='serverName=docker' \
  cn007b/php php index.php

Composer:

docker run -it --rm cn007b/php composer

Protocol Buffers (ptotobuf):

docker run -it --rm cn007b/php protoc --version

Built-in web server:

docker run -it --rm -v $PWD:/app -w /app -p 80:80 \
  cn007b/php php -S 0.0.0.0:80 index.php

Now open in browser localhost.

Nginx:

docker run -it --rm -v $PWD:/app -w /app -p 80:80 cn007b/php /bin/bash -c '
    service php7.1-fpm start;
    service nginx start;
    tail -f /dev/stdout
  '

Now open in browser localhost/index.php.

Add to end of URL ?XDEBUG_SESSION_START=PHPSTORM with purpose to use Xdebug.

Nginx with custom config:

docker run -it --rm -v $PWD:/app -w /app -p 80:80 \
  -v $PWD/nginx.default.conf:/etc/nginx/conf.d/default.conf \
  cn007b/php /bin/bash -c '
    service php7.1-fpm start;
    service nginx start;
    tail -f /dev/stdout
  '

Configure Xdebug:

Set debug port in your IDE to 9002 and create IP alias 10.254.254.254 to your host machine, for OSX use: sudo ifconfig lo0 alias 10.254.254.254, for Ubuntu use: sudo ifconfig lo 10.254.254.254 up.

About

🐳 This repo contains PHP docker images tailored for development purposes (xdebug, composer, php-fpm, nginx, etc).

https://hub.docker.com/r/cn007b/php/

License:MIT License