Before developing applications in any new language/platform I make sure that the debugger works in the set up. I had been working on some projects in Python and PHP recently and I have already shared my notes on setting up and debugging Python (Django) application in Docker and how to debug the application.
In this post I will describe how to setup PHP7 in Docker and debug the application. You can checkout the project from this Github repo.
Here is the Docker file for this setup –
FROM php:7.0.17-apache RUN apt-get update RUN apt-get install -y apt-utils vim curl sqlite3 RUN pecl install xdebug # copy test db file ADD ./db/employee.db /employee.db # The base image does not have php.ini. # Copy our own, with xdebug settings ADD ./php.ini /usr/local/etc/php/ EXPOSE 80
To debug PHP applications, you need to install xdebug. In the docker file it is installed using pecl. Then employee.db (Sqlite3 DB) is copied from the project folder to the root of docker container.