Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XDebug not available #66

Open
Stefan39 opened this issue Oct 9, 2023 · 5 comments
Open

XDebug not available #66

Stefan39 opened this issue Oct 9, 2023 · 5 comments
Labels

Comments

@Stefan39
Copy link

Stefan39 commented Oct 9, 2023

Hi Dave,

on my .env file I have enabled XDebug:

...
PHP_ENABLE_XDEBUG=TRUE
PHP_MEMORY_LIMIT=2G
PHP_XDEBUG_MODE=develop
PHP_XDEBUG_CLIENT_HOST=host.docker.internal
PHP_XDEBUG_CLIENT_PORT=9003

my docker-compose.yml:

services:

  php:
    build: ./docker
    container_name: "${PROJECT_NAME}-app"
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=web"
      - "traefik.http.routers.${PROJECT_NAME}.rule=Host(`${PROJECT_NAME}.${DOMAIN_SUFFIX}`)"
    env_file:
      - ./.env
    ports:
      - "9003:9003"
    volumes:
      # Source code
      - ./app:/www/html
    networks:
      frivol:
      web:
        aliases:
          - "${PROJECT_NAME}.${DOMAIN_SUFFIX}"
networks:
  frivol:
    driver: bridge
  web:
    external: true

but xdebug are not available on web and also on cli.

My Dockerfile:

FROM tiredofit/nginx-php-fpm:debian-8.2

# additional ENV vars
ENV NODE_VERSION=20.5.1
ENV NVM_DIR=/root/.nvm

# since we don't use zabbix remove it right away
ENV CONTAINER_ENABLE_MONITORING=false

# Install NVM for node
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
RUN . "$NVM_DIR/nvm.sh" \
    && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" \
    && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" \
    && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"

# Install npm and yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt update \
    && apt install vim nodejs yarn -y

RUN php-ext enable redis \
    && php-ext enable calendar \
    && php-ext enable zip

I have see an old issue what closed by inactivity for php-5.6. I have also try it to enable byself && php-ext enable xdebug but this also not works.

Unfortunatelly i cannot test it with alpine or other image at time. Do you know what's going wrong here?

@Stefan39 Stefan39 added the bug label Oct 9, 2023
@tiredofit
Copy link
Owner

Yipes, it's been a while since I built in the XDebug feature for someone, near 5 years now. We had someone work on it in the past 2 years I believe to get it going with XDebug3?

PR was #35
@Unlink are you able to give us a hand here to get XDebug working?

@Stefan39
Copy link
Author

@tiredofit I'm using the ENV vars for xdebug3. Hopefully @Unlink can help.

@Stefan39
Copy link
Author

Hm, I'm just wondering, /etc/php/8.2/fpm/conf.d/20-xdebug.ini are available and enabled, but phpinfo doesn't show it as active.

/etc/php/8.2/fpm/conf.d/20-xdebug.ini:

zend_extension=xdebug.so
  zend_extension=xdebug.so
  xdebug.default_enable = 1
  xdebug.output_dir = /www/logs/php-fpm/xdebug/
  xdebug.mode = develop
  xdebug.start_with_request = default
  xdebug.discover_client_host = default
  xdebug.client_host = host.docker.internal
  xdebug.client_port = 9003

@Unlink
Copy link
Contributor

Unlink commented Oct 13, 2023

@Stefan39 it looks weird, if you check phpinfo() do you see it here?
obrázok

my 20-xdebug.ini looks like this

zend_extension=xdebug.so
  zend_extension=xdebug.so
  xdebug.default_enable = 1
  xdebug.output_dir = /www/logs/php-fpm/xdebug/
  xdebug.mode = debug
  xdebug.start_with_request = 1
  xdebug.discover_client_host = default
  xdebug.client_host = host.docker.internal
  xdebug.client_port = 9003

using configuration

"PHP_ENABLE_XDEBUG=TRUE"
"PHP_XDEBUG_MODE=debug"
"PHP_XDEBUG_START_WITH_REQUEST=1"
"PHP_XDEBUG_CLIENT_HOST=host.docker.internal"

you also should remove ports configuration from your docker compose, port 9003 is opened by your IDE and xdebug in docker is connecting to it. If you expose it, you probably cannot start listening for debug connections

ports:
  - "9003:9003"

@Stefan39
Copy link
Author

Thanks @Unlink, i must use another port for PHP_XDEBUG_CLIENT_PORT because PHPStorm will stop by "port is busy". If I'm using another port (i.e. 61355) it works after i remove port exposing in docker-compose.

Unfortunately PHPStorm's Unit-testing not working because not found the autoloader in /www/html/vendor/autoload.php I'm unsure if the file permission are the problem (all files in vendor are owned by root:root) or another problem is the reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants