Public Repository

Last pushed: a month ago
Short Description
Image for local PHP development and testing using apache, php-farm, Z-Ray and MariaDB
Full Description

If you have a project inside /projects/myproject and you want to fire up an environment for development and testing on that project. Inside the project folder you can run

docker run --rm -t -i -v $PWD\:/var/www:rw -v $PWD/dbdata:/var/lib/mysql -v $PWD/etc/mysql:/etc/mysql -v $PWD/etc/apache2:/etc/apache2 -e MYSQL_ROOT_PASSWORD="root" -p 8052:8052 -p 8053:8053 -p 8054:8054 -p 8055:8055 -p 8056:8056 -p 8070:8070 -p 8071:8071 -p 3306:3306 inquam/phpdev

This will run an image with php versions on different ports. 8052 will be php 5.2, 8053 will be PHP 5.3 etc.

A folder dbdata will be created in your project folder that will house the MariaDB database files so they will persist for the next time you run an image. You can also make /etc/mysql and /etc/apache2 available so you can edit configurations for your project.

You can of course place these data folders in other places but I like to have them in the project folder, sync the project folder between my computers so I can continue development on another computer, start the image and have all the settings and data.

Note that PHP 5.6 also comes configured with Z-Ray to allow insight into code calls etc. When this is available for PHP7 I'll add it for that to.

To quickly start the environment for your project you can put a small start up script in your project folder. For windows that could look like

@ECHO OFF
PowerShell.exe -Command "& docker run --rm -t -i -v $PWD\:/var/www:rw -v $PWD/dbdata:/var/lib/mysql -v $PWD/etc/mysql:/etc/mysql -v $PWD/etc/apache2:/etc/apache2 -e MYSQL_ROOT_PASSWORD="root" -p 8052:8052 -p 8053:8053 -p 8054:8054 -p 8055:8055 -p 8056:8056 -p 8070:8070 -p 8071:8071 -p 3306:3306 -p 10081:10081 -p 10083:10083 inquam/phpdev"
PAUSE

Name the file something like startdevenv.bat and just double click it to start your environment. To be able to run multiple environments at the same time for different projects. Make sure you change the ports on the images so they don't collide.

Docker Pull Command
Owner
inquam

Comments (0)