I created a Docker image that bundles PHP (with Apache), Xdebug and PHPUnit which I can start with docker-compose in the terminal.
version: '3'
services:
php-apache-xdebug-phpunit:
image: php-apache-xdebug-phpunit:7.2
ports:
- "80:80"
volumes:
- ./src:/var/www/html
restart: always
I want to use the PhpStorm integration with docker-compose but when I configure the CLI interpreter, I get two errors (screenshot):
- BadRequestException -> invalid environment variable (I think an empty value should be possible actually)
- PHP version: not installed (it's partially visible in the screenshot)
The Dockerfile for completeness sake:
FROM php:7.2-apache-stretch
##########
# XDebug #
##########
# Install
RUN pecl install xdebug-2.6.1 && docker-php-ext-enable xdebug
# Configure
RUN echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so"' >> /usr/local/etc/php/php.ini
RUN echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "display_startup_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "display_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.idekey=\"PHPSTORM\"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
###########
# PHPUnit #
###########
RUN apt-get update
RUN apt-get install wget
RUN wget https://phar.phpunit.de/phpunit-7.4.phar
RUN chmod +x phpunit-7.4.phar
RUN mv phpunit-7.4.phar /usr/local/bin/phpunit
RUN phpunit --version
###################
# PHP Codesniffer #
###################
RUN curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
RUN mv phpcs.phar /usr/local/bin/phpcs
RUN chmod +x /usr/local/bin/phpcs