So, my configurations are:
- Dockerfile:
FROM php:8.1-apache as php_base
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN a2enmod rewrite && install-php-extensions pgsql
RUN echo 'ServerName localhost' >> /etc/apache2/apache2.conf && service apache2 restart
WORKDIR /var/www/lessor-calculator
FROM php_base as php_dev
RUN pecl install xdebug && docker-php-ext-enable xdebug
- docker-compose.yml:
version: "3.4"
services:
app:
build:
context: docker/server
target: php_dev
networks:
my-network:
environment:
PHP_IDE_CONFIG: "serverName=MyApp"
ports:
- "${DOCKER_SERVER_PORT:-9180}:80"
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./:/var/www/lessor-calculator
- ./docker/server/apache/sites-enabled:/etc/apache2/sites-enabled
- ./docker/server/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
- ./docker/server/php/conf.d/xdebug.log:/var/log/xdebug.log
- ./docker/server/php/conf.d/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini
xdebug_info()
output:
- PhpStorm settings:
- Xdebug log:
[17] Log opened at 2022-01-04 14:47:45.645181
[17] [Step Debug] INFO: Connecting to configured address/port: host.docker.internal:9003.
[17] [Step Debug] WARN: Creating socket for 'host.docker.internal:9003', poll success, but error: Operation now in progress (29).
[17] [Step Debug] ERR: Could not connect to debugging client. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(
[17] Log closed at 2022-01-04 14:47:45.649491
Also I've tried to use another port, curl host.docker.internal:9000
, with answer "Connection refused", (but just ping host.docker.internal
is work fine). Everyone said, that there's no need to map 9000 port.
Please any suggestion, what reason could be. Thank you.
UPDATE: Xdebug conf:
zend_extension=xdebug
[xdebug]
xdebug.mode=debug
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes
xdebug.log="/var/log/xdebug.log"
Update: new configuration for 9003 port, enable xdebug.log
Update 2: i'm using rootless docker. And i've checked it's all work in rootfull mode.
My Answer:
't be installed via PECL anymore. Instead, you can install Xdebug 3 using the following steps:
1. Download the Xdebug 3 source code from the official website: https://xdebug.org/download.php
2. Extract the downloaded file and navigate to the extracted directory.
3. Run the following commands to build and install Xdebug 3:
phpize
./configure
make
sudo make install
4. Add the following line to your php.ini file to enable Xdebug 3:
zend_extension=xdebug.so
5. Restart your web server to apply the changes.
You can also check the official Xdebug documentation for more detailed installation instructions: https://xdebug.org/docs/install
Rate this post
4 of 5 based on 4413 votesComments