Al utilizar el sitio web AlfaVila.com, acepta el uso de cookies para mejorar el nivel de servicio.

Debugging in PHP with XDebug 3 and Docker/Podman Compose

docker-compose.yml

version: '3'
services:

# PHP Service
php-fpm:
container_name: myapp
build: docker/php
restart: always
# user: app
volumes:
- ./data/Laravel:/var/www/html
- ./logs/php.log:/var/log/fpm-php.www.log

# Nginx Service
nginx:
build: docker/nginx
restart: unless-stopped
ports:
- "8080:80"
volumes:
- ./data/Laravel:/var/www/html
- ./logs/nginx:/var/log/nginx/

docker/nginx/Dockerfile

FROM nginx:alpine
COPY default.conf /etc/nginx/conf.d/default.conf

docker/nginx/default.conf

server {
listen 80;
index index.php;
server_name myapp.site;

root /var/www/html/public;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \\.php$ {
include fastcgi_params;
fastcgi_pass php-fpm:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}

docker/php/Dockerfile

FROM php:8.1-fpm-alpine

# Info: https://github.com/mlocati/docker-php-extension-installer
RUN curl -sSLf \\
-o /usr/local/bin/install-php-extensions \\
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \\
chmod +x /usr/local/bin/install-php-extensions && \\
install-php-extensions xdebug

# Configure Xdebug, create docker-php-ext-xdebug.ini with: zend_extension=xdebug.so
#RUN docker-php-ext-enable xdebug
RUN echo "xdebug.mode=develop,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \\
&& echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \\
&& echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

PhpStorm configuration:

ifconfig docker0

/etc/hosts
# XDebug for docker
172.17.0.1      host.docker.internal

Debugging in PHP with XDebug 3 and Docker/Podman Compose

Comparte este post

¿Cómo funciona Scrumban?

La metodología Scrumban toma características tanto de la estrategia Scrum como de Kanban. El proceso