yiisoft / yii2-docker

Official Docker images suitable for Yii 2.0
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
384 stars 202 forks source link

Images at DockerHub are built without xdebug support #75

Closed whocaresk closed 5 years ago

whocaresk commented 5 years ago

And there is no way to enable it during build. At this moment docs are misleading and make you think that putting PHP_ENABLE_XDEBUG=1 in .env or docker-compose file will really enable xdebug.

example Dockerfile:

FROM yiisoftware/yii2-php:7.3-apache

WORKDIR /app

COPY ./composer* ./

RUN composer install --ignore-platform-reqs && \
    mv vendor/bower-asset vendor/bower

COPY ./docker/config/000-default.conf /etc/apache2/sites-available/000-default.conf

COPY . .
version: '3.2'

services:
  backend:
    build:
      dockerfile: Dockerfile
      context: .
    ports:
    - 1337:80
    volumes:
    # Re-use local composer cache via host-volume
    - ~/.composer-docker/cache:/root/.composer/cache:delegated
    # Mount source-code for development
    - ./:/app
    - /app/vendor/
    environment:
    - PHP_ENABLE_XDEBUG=1

We can ensure that there is no files was created for xdebug (config, etc) by logging into created container and checking /etc/php/conf.d/xdebug.ini (there is no such file)

whocaresk commented 5 years ago

Seems like there is problem with my configuration. I'll close issue. Phpstorm still doesn't receive connection, but trouble definitely is on my side screenshot

kristian-94 commented 4 years ago

@whocaresk I am getting this issue right now, my phpstorm looks just like that. Do you remember how you fixed it? Thanks

whocaresk commented 4 years ago

@whocaresk I am getting this issue right now, my phpstorm looks just like that. Do you remember how you fixed it? Thanks

try this xdebug.ini:

;zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=0
xdebug.remote_connect_back=1
;;; if you are on macOS, use host.docker.internal to identify the host machine, due to a network limitation on mac (https://docs.docker.com/docker-for-mac/networking/#port-mapping)
;;; otherwise find host ip
;;; xdebug.remote_host=host.docker.internal
;;; avoid standard port (9000) conflicts using 9005 port
xdebug.remote_port=9005
xdebug.idekey=PHPStorm

and put this line into your Dockerfile: COPY ./path/to/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini

don't forget to set PHP_ENABLE_XDEBUG=1 env var. and path mappings also: Снимок экрана от 2020-10-29 16-03-36