🌐
Medium
medium.com › @salmanahmad98 › php-application-setup-on-docker-8229798caa60
A Beginner’s Walkthrough: Dockerizing PHP 8.2 and Enabling Xdebug | by Salman Ahmad | Medium
March 2, 2024 - Create a file named Dockerfile inside the docker/php82 folder and add the provided content. FROM php:8.2-apache USER root WORKDIR /var/www/html RUN apt-get update && \ apt-get install -y vim wget RUN a2enmod rewrite COPY xdebug-3.3.1.tgz /tmp/ RUN cd /tmp && tar -xzvf xdebug-3.3.1.tgz && \ cd xdebug-3.3.1 && \ phpize && \ ./configure && \ make && \ make install # Copy Apache configuration COPY apache-config.conf /etc/apache2/sites-available/000-default.conf # AllowOverride for .htaccess RUN sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/apache2
🌐
GitHub
github.com › ChrisB9 › php8-xdebug
GitHub - ChrisB9/php8-xdebug: PHP 8.0 for development and production usage. With nginx, brotli, xdebug, JIT and more...
If docker socket has been mounted as a volume into the container, then each startup checks the availability of the docker command and if not available installs it. Note: This is currently only available in alpine images: WIP · Some xdebug settings have been preconfigured, such as: ... in the app-folder are two files index.php and Test.php. They are meant as a playground to test the newest features of php 8.0
Starred by 16 users
Forked by 7 users
Languages   Dockerfile 54.6% | Rust 26.4% | Shell 12.9% | PHP 6.0% | Vim Script 0.1% | Dockerfile 54.6% | Rust 26.4% | Shell 12.9% | PHP 6.0% | Vim Script 0.1%
Discussions

Help to get PHP8 w/ xdebug in Docker on OSX running for local dev (phpunit) via PhpStorm in a checkout project
If I'm correct phpstorm can also run composer update on the remote interpreter thus will allow you to install php8 dependencies. Or try setting php 8 in your composer.json check out https://andy-carter.com/blog/composer-php-platform for example. Or run composer install --ignore-platform-reqs on your hist, this will ignore the php and extension constraints. More on reddit.com
🌐 r/PHPhelp
21
7
November 14, 2020
php - Installing XDebug in Docker - Stack Overflow
I solved this by adding the following lines into my Docker file: # "xdebug-2.9.0" for PHP<=7.4 — "xdebug" (3) for PHP>=8 ARG XDEBUG_VERSION="xdebug-2.9.0" FROM php:7.0-apache RUN a2enmod rewrite RUN docker-php-ext-install pdo pdo_mysql RUN yes | pecl install ${XDEBUG_VERSION} \ && echo ... More on stackoverflow.com
🌐 stackoverflow.com
Getting xdebug to work with my container
I’ve struggled to get a dev environment setup and running with a persistent database and with xdebug installed. I finally managed to get my container going with a persistent database and I did finally manage to get xdebug installed with my container. But I am still not getting xdebug to work ... More on forums.docker.com
🌐 forums.docker.com
17
0
March 9, 2024
xdebug not installed on php 8.3 docker container - Stack Overflow
I'm using this Dockerfile FROM php:8.3-apache RUN pecl install xdebug-3.3.2 && docker-php-ext-enable xdebug RUN apt-get update && apt-get install -y \ libfreetype6-dev \ More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › sineverba › php8xc
GitHub - sineverba/php8xc: Docker image for PHP8 with Xdebug and Composer · GitHub
Docker image built from PHP8.y.z CLI official + Xdebug + Composer, for linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 architectures.
Starred by 21 users
Forked by 5 users
Languages   Makefile 61.2% | Dockerfile 38.8%
🌐
Docker Hub
hub.docker.com › r › chrisb9 › php8-nginx-xdebug
chrisb9/php8-nginx-xdebug - Docker Image
Welcome to the world's largest container registry built for developers and open source contributors to find, use, and share their container images. Build, push and pull.
🌐
Docker Hub
hub.docker.com › r › mobtitude › php-xdebug
mobtitude/php-xdebug - Docker Image
mobtitude/php-xdebug:8.3-fpm · mobtitude/php-xdebug:8.4-apache · mobtitude/php-xdebug:8.4-cli · mobtitude/php-xdebug:8.4-fpm · These tags are still available in docker hub, but no further updates will be provided: mobtitude/php-xdebug:5.6-apache · mobtitude/php-xdebug:5.6-cli ·
🌐
Pascallandau
pascallandau.com › blog › phpstorm-docker-xdebug-3-php-8-1-in-2022
PhpStorm, Docker and Xdebug 3 on PHP 8.1 in 2022 [Tutorial Part 3] | pascallandau.com
We also don't want to enable xdebug immediately but only when we need it (due to the decrease in performance when the extension is enabled), hence we remove the default config file and disable the extension in the application .ini file · # File: .docker/images/php/base/conf.d/zz-app-local.ini ; Note: ; Remove the comment ; to enable debugging ;zend_extension=xdebug xdebug.client_host=host.docker.internal xdebug.start_with_request=yes xdebug.mode=debug
🌐
Reddit
reddit.com › r/phphelp › help to get php8 w/ xdebug in docker on osx running for local dev (phpunit) via phpstorm in a checkout project
r/PHPhelp on Reddit: Help to get PHP8 w/ xdebug in Docker on OSX running for local dev (phpunit) via PhpStorm in a checkout project
November 14, 2020 -

SOLVED

See https://www.reddit.com/r/PHPhelp/comments/jti8i2/help_to_get_php8_w_xdebug_in_docker_on_osx/gc7g8j5/?utm_source=reddit&utm_medium=web2x&context=3 for the summary

Thanks everyone!


I've never really used docker before and I'm hitting so many walls that I stopped counting, I think today (Friday 13th) is my lucky day.

What I currently have:

  • Host OSX

  • PHP 7.4 installed via brew

  • git clone of my project

  • phpunit tests are running, also inside PhpStorm

  • I can also debug, I've xdebug installed via pecl

What I'm trying to achieve:

  • same as above but with PHP 8 without replacing my brew PHP 7.4; this is intended only for local dev

  • I don't need webserver etc., just CLI

  • PHP 8.0 (e.g. the php:8.0.0RC4-cli image I guess?)

  • being able to install the composer dependencies via PHP within docker, important for package version resolving (this project will install different version on different PHP version to be compatible)

  • run phpunit (ideally also via PhpStorm)

  • super bonus: also get xdebug working in the docker image (probably need to add further install steps with pecl in Dockerfile?) so it also works via PhpStorm

In fact, I don't know how, I got it working that I can run phpunit and it runs it in the docker image; but I'm too stupid to figure out how to also run composer inside the image. I don't even know of composer is available in this image 🤷‍♀️

Dockerfile I have (don't laugh):

FROM php:8.0.0RC4-cli

ADD ./ /app

WORKDIR /app

Docker composer (because no idea, tutorials and stuff):

version: '3'

services:
    php:
        build: .
        volumes:
            - ./:/app
        working_dir: '/app'

I then did docker-compose build and the resulting image I selected in PhpStorm (remote interpreter) and managed to get phpunit running.

It "works" but the vendor files are still from my local host PHP composer installation and they contain incompatible code with PHP8 (e.g. classes like Match 💥), thus I need fix that but no idea (aka run composer in Docker with PHP 8).

Is anyone willing / has the energy and time to help me moving forward? Would be much appreciated :)

Thanks

Find elsewhere
🌐
Laravel News
laravel-news.com › home › laravel tutorials › get xdebug working with docker and php 8.4 in one minute
Get Xdebug Working With Docker and PHP 8.4 in One Minute - Laravel News
December 31, 2024 - In fact, I am confident that you can start using Xdebug with Docker in about a minute. OK, maybe it will take some of you a few minutes :) We will demonstrate the setup with Laravel, PHP 8.4 and Xdebug v3.4.0, the latest stable versions at the time of writing.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 8531104094994-Properly-setup-xdebug-with-PHP-Apache-Docker-Container-including-composer
Properly setup xdebug with PHP Apache Docker Container including composer – IDEs Support (IntelliJ Platform) | JetBrains
November 11, 2022 - FROM php:8.1-apache WORKDIR /var/www/html/ RUN pecl install xdebug \ && apt update \ && apt install libzip-dev -y \ && docker-php-ext-enable xdebug \ && a2enmod rewrite \ && docker-php-ext-install zip \ && rm -rf /var/lib/apt/lists/* COPY --from=composer:latest /usr/bin/composer /usr/bin/composer COPY composer.json .
🌐
Daily.dev
app.daily.dev › home › laravel news › get xdebug working with docker and php 8.4 in one minute
Get Xdebug Working With Docker and PHP 8.4 in One Minute | daily.dev
January 16, 2025 - Learn how to easily set up Xdebug with Docker and PHP 8.4, using Laravel. This guide includes configuring a Dockerfile, setting up Apache, and tweaking PhpStorm for debugging.
🌐
GitHub
github.com › mobtitude › docker-php-xdebug
GitHub - mobtitude/docker-php-xdebug: Docker images with PHP and xdebug installed, configured and ready to debug and profile applications in modern IDEs. · GitHub
The only difference is that, instead of downloading official Docker PHP image, you have to use one of the images listed below. Supported tags: mobtitude/php-xdebug:8.1-apache · mobtitude/php-xdebug:8.1-cli · mobtitude/php-xdebug:8.1-fpm · mobtitude/php-xdebug:8.2-apache ·
Starred by 20 users
Forked by 8 users
Languages   Dockerfile 61.9% | Shell 31.6% | Makefile 3.7% | PHP 2.8%
🌐
Medium
medium.com › @arielmagbanua › debug-like-a-pro-setting-up-xdebug-in-docker-for-phpstorm-a2394c2fab75
Xdebug Configuration in Docker for PHPStorm | by Ariel Magbanua | Medium
April 28, 2025 - The instructions will install xdebug and then enable it, and it will execute copy of your own xdebug.ini configutation to /usr/local/etc/php/conf.d/ directory of the container. # Use the official PHP image from Docker Hub FROM php:8.4-apache # Install required PHP extensions and dependencies RUN apt-get update && apt-get install -y unzip git libpng-dev libjpeg-dev libfreetype6-dev \ && docker-php-ext-install pdo pdo_mysql gd # Install Xdebug RUN pecl install xdebug \ && docker-php-ext-enable xdebug # Copy xdebug.ini configuration file to PHP's conf.d directory COPY xdebug.ini /usr/local/etc/ph
🌐
Medium
medium.com › the-sensiolabs-tech-blog › how-to-use-xdebug-in-docker-phpstorm-76d998ef2534
How to use Xdebug in Docker & PhpStorm | The SensioLabs Tech Blog
June 14, 2022 - So, let’s consider this simple Dockerfile as our base. ... It is missing quite a few things to make our app actually work, but I’m only showing the relevant parts. Now let’s add Xdebug inthere · COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/RUN install-php-extensions xdebug
🌐
Heigl
andreas.heigl.org › home › xdebug in docker
Xdebug in Docker - andreas.heigl.org »
November 7, 2023 - One thing though that Dmitri skips though (an dfor good reasons) is how to get Xdebug into your Docker environment. As I have done that quite a number of times by now I thought I’d share the way I do it currently. ... FROM php:8.3-rc-fpm RUN PHPIZE_DEPS="autoconf \ cmake \ file \ g++ \ gcc \ libc-dev \ libpcre2-dev \ make \ git \ pkgconf \ re2c" \ && XDEBUG_VERSION="" \ && if [ "$(php -v | head -n 1 | grep 8.3)" != "" ]; then XDEBUG_VERSION="-3.3.0alpha3"; fi \ && apt-get update \ && apt-get install -y $PHPIZE_DEPS \ && pecl install xdebug${XDEBUG_VERSION} \ && docker-php-ext-enable xdebug \ && echo "xdebug.mode=debug\nxdebug.discover_client_host=on\nxdebug.start_with_request=yes\nxdebug.log_level=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ && apt-get remove -y $PHPIZE_DEPS
🌐
JetBrains
jetbrains.com › help › phpstorm › configuring-xdebug.html
Configure Xdebug | PhpStorm Documentation
If you are using Docker for Windows or Docker for Mac, you can set xdebug.remote_host to host.docker.internal, which automatically resolves to the internal address of the host, letting you easily connect to it from the container. To configure Xdebug running on a Vagrant instance, connect to the Vagrant machine and provide the Xdebug-specific parameters in the php.ini file:
🌐
DEV Community
dev.to › _mertsimsek › using-xdebug-with-docker-2k8o
Using Xdebug with Docker - DEV Community
April 8, 2019 - For this, follow this path from the interface. Phpstorm > Preferences > PHP > Debug. You are going to see Xdebug Debug Port. You should change as 9001 port. After that, follow this path Phpstorm > Preferences > PHP > Servers.
🌐
Stack Overflow
stackoverflow.com › questions › 78972915 › xdebug-not-installed-on-php-8-3-docker-container
xdebug not installed on php 8.3 docker container - Stack Overflow
FROM php:8.3-apache RUN pecl install xdebug-3.3.2 && docker-php-ext-enable xdebug RUN apt-get update && apt-get install -y \ libfreetype6-dev \ libjpeg62-turbo-dev \ libpng-dev \ libzip-dev \ zip \ && docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-install -j$(nproc) gd pdo pdo_mysql zip RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini RUN echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini RUN echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini RUN a2enmod rewrite EXPOSE 9003 WORKDIR /var/www/html COPY apache-config.conf /etc/apache2/sites-available/000-default.conf COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer CMD ["apache2-foreground"]
🌐
Medium
medium.com › @fico7489 › install-xdebug-in-your-docker-php-container-and-then-enable-and-disable-any-time-when-you-want-d8ac31ae53f4
Install “xdebug” in your docker PHP container and then enable and disable any time when you want | by Filip Horvat | Medium
February 20, 2023 - “app_php_dev” —dev image where xdebug is installed “app_php_dev_performance” —dev image where xdebug is not installed “app_php_prod” — production image · We will add this 3 stages into the .docker/php/Dockerfile: FROM php:8.1-fpm-alpine AS app_php RUN echo ‘app_php’ FROM app_php AS app_php_dev RUN echo 'app_php_dev' #define custom options for "app_php_dev" FROM app_php AS app_php_dev_performance RUN echo ‘app_php_dev_performance’ #define custom options for “app_php_dev_performance” FROM app_php AS app_php_prod RUN echo 'app_php_prod' #define custom options for "app_php_prod"