在PhpStorm 2017.3.2中设置docker-compose

时间:2018-11-24 09:15:23

标签: php docker docker-compose phpstorm

我创建了一个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解释器时,出现两个错误(截图):

  • BadRequestException->无效的环境变量(我认为实际上应该有一个空值)
  • PHP版本:未安装(在屏幕截图中部分可见)

PhpStorm docker-compose config error

出于完整性考虑,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

0 个答案:

没有答案