我创建了一个Docker映像,该映像将PHP(与Apache),Xdebug和PHPUnit捆绑在一起,可以在终端中以docker-compose开头。
version: '3'
services:
php-apache-xdebug-phpunit:
image: php-apache-xdebug-phpunit:7.2
ports:
- "80:80"
volumes:
- ./src:/var/www/html
restart: always
我想将PhpStorm集成与docker-compose结合使用,但是在配置CLI解释器时,出现两个错误(截图):
出于完整性考虑,Dockerfile:
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