Feature Request: Xdebug #14

Open
opened 2025-03-01 20:02:52 +00:00 by cpaschen · 16 comments

Thanks for this script. Just jumping back into development and giving it a try and wondering if there is already a way to enable Xdebug within the container using octojoom that I missed or if that might be possible to add-in to the script?

If it's already possible, within the script or with minor manual modifications of the script, let me know.

I know that we can add php.ini directives now but not sure how to actually add the Xdebug run command to get it started.

Thanks for this script. Just jumping back into development and giving it a try and wondering if there is already a way to enable Xdebug within the container using octojoom that I missed or if that might be possible to add-in to the script? If it's already possible, within the script or with minor manual modifications of the script, let me know. I know that we can add php.ini directives now but not sure how to actually add the Xdebug run command to get it started.
Owner

We previously considered adding Xdebug functionality but didn’t move forward with it. However, given the renewed interest, I’m open to incorporating it in a way that allows it to be easily enabled or disabled with a simple override.

I currently don’t use Xdebug myself, so I haven’t had the time to work through the setup. That said, I know others have asked for it, and I’d be happy to implement it if I have all the necessary details. If you can provide the exact configurations needed, such as where to modify settings, which ports need to be opened, and any additional changes required in php.ini I’ll make sure it can be toggled on or off easily.

Let me know what’s needed, and I’ll take care of integrating it properly.

We previously considered adding Xdebug functionality but didn’t move forward with it. However, given the renewed interest, I’m open to incorporating it in a way that allows it to be easily enabled or disabled with a simple override. I currently don’t use Xdebug myself, so I haven’t had the time to work through the setup. That said, I know others have asked for it, and I’d be happy to implement it if I have all the necessary details. If you can provide the exact configurations needed, such as where to modify settings, which ports need to be opened, and any additional changes required in `php.ini` I’ll make sure it can be toggled on or off easily. Let me know what’s needed, and I’ll take care of integrating it properly.
Author

I'm still a bit of a newbee with docker, so I'm not completely sure how to set it up.

I know when dealing directly I just have to install xdebug and then add a link in PHP.ini to tell it where it is.
I do know that the default port is 9000.

I've gone through a number of docs online and all of them indicate adding RUN commands via the Docerfile. I thought I'd give it a test with my site here generated with octojoom, but I can't seem to find the docker file ... only docker-compose yaml - but I don't think that these are translateable, or able to run pecl from the docker-compose file. But again, I'm way over my head with that.

The one set of instructions that seems to almost work for me is:
https://phauer.com/2017/debug-php-docker-container-idea-phpstorm/

Although I'm using PHPStorm, so that's especially applicable for me, the first section of code is pretty generic (although the versions are outdated.

If you can point me in the direction of where to add the RUN pecl install xdebug (and other RUN) lines, I could do some work to test to get the details worked out test it a bit.

BTW ... adding the php.ini parts works fine just adding manually within octojoom for now.
If there were a way to manually add those 2 RUN commands, then I think it would work.

I'm still a bit of a newbee with docker, so I'm not completely sure how to set it up. I know when dealing directly I just have to install xdebug and then add a link in PHP.ini to tell it where it is. I do know that the default port is 9000. I've gone through a number of docs online and all of them indicate adding RUN commands via the Docerfile. I thought I'd give it a test with my site here generated with octojoom, but I can't seem to find the docker file ... only docker-compose yaml - but I don't think that these are translateable, or able to run pecl from the docker-compose file. But again, I'm way over my head with that. The one set of instructions that seems to almost work for me is: https://phauer.com/2017/debug-php-docker-container-idea-phpstorm/ Although I'm using PHPStorm, so that's especially applicable for me, the first section of code is pretty generic (although the versions are outdated. If you can point me in the direction of where to add the ```RUN pecl install xdebug``` (and other RUN) lines, I could do some work to test to get the details worked out test it a bit. BTW ... adding the php.ini parts works fine just adding manually within octojoom for now. If there were a way to manually add those 2 RUN commands, then I think it would work.
Author

So, if we have a Dockerfile, it would need to include:

FROM php:8.0-apache

RUN apt-get update &&\
    apt-get install --no-install-recommends --assume-yes --quiet ca-certificates curl git &&\
    rm -rf /var/lib/apt/lists/*

RUN pecl install xdebug-3.2.0 && docker-php-ext-enable xdebug

And the PHP.ini will need to have added:

zend_extension="<path_to_where_xdebug_gets_installed>/xdebug.so"
xdebug.remote_port=9000
xdebug.remote_enable=1
xdebug.remote_connect_back=1

I think that should be it (with making port 9000 accessible)

So, if we have a Dockerfile, it would need to include: ``` FROM php:8.0-apache RUN apt-get update &&\ apt-get install --no-install-recommends --assume-yes --quiet ca-certificates curl git &&\ rm -rf /var/lib/apt/lists/* RUN pecl install xdebug-3.2.0 && docker-php-ext-enable xdebug ``` And the PHP.ini will need to have added: ``` zend_extension="<path_to_where_xdebug_gets_installed>/xdebug.so" xdebug.remote_port=9000 xdebug.remote_enable=1 xdebug.remote_connect_back=1 ``` I think that should be it (with making port 9000 accessible)
Author

BTW ... if you have a different debug utility that you recommend instead of xDebug, that can provide step debugging for PHP, I'd be open to use that, rather than trying to change Octojoom.

(I switched to Ubuntu so that I could use Octojoom, and if switching to a different debugger will put me more in-line with others using JCB, I'd be willing to switch to that also.)

BTW ... if you have a different debug utility that you recommend instead of xDebug, that can provide step debugging for PHP, I'd be open to use that, rather than trying to change Octojoom. (I switched to Ubuntu so that I could use Octojoom, and if switching to a different debugger will put me more in-line with others using JCB, I'd be willing to switch to that also.)
Owner

We will be adding extra Images to the official docker images of Joomla, for xdebug. The has been decided months ago in the maintainers channel... I have just not had time to do it, as yet... so when this issue came up, I thought I could ask for some help with all the needed changes I need to make to the images... to ensure a stable dev ready set of images can be build. So we will first bump Joomla with a new set of images just for dev (extension focused development, not for Joomla core testing and development) and then we will improve OctoJoom to make full use of this 🚀

We will be adding extra Images to the official docker images of Joomla, for xdebug. The has been decided months ago in the maintainers channel... I have just not had time to do it, as yet... so when this issue came up, I thought I could ask for some help with all the needed changes I need to make to the images... to ensure a stable dev ready set of images can be build. So we will first bump [Joomla with a new set of images](https://github.com/joomla-docker/docker-joomla) just for dev (extension focused development, not for Joomla core testing and development) and then we will improve [OctoJoom](https://git.vdm.dev/octoleo/octojoom) to make full use of this 🚀
Author

I didn't see a ticket over on the Joomla docker github page for this.
Let me know if there is some place to join in there.
I can't really help all that much with creating the code to do this, because I'm still new to the process of creating docker images, but I'm definitely willing to test out anything when needed (or help with documenting).

BTW ... I'm still working on migrating some J3 sites over to J4/5, so having xdebug available with the last J3 image would be helpful.

I didn't see a ticket over on the Joomla docker github page for this. Let me know if there is some place to join in there. I can't really help all that much with creating the code to do this, because I'm still new to the process of creating docker images, but I'm definitely willing to test out anything when needed (or help with documenting). BTW ... I'm still working on migrating some J3 sites over to J4/5, so having xdebug available with the last J3 image would be helpful.
Owner

I didn't see a ticket over on the Joomla docker github page for this.

This was a conversation in the CMS Maintainers team meeting, and it was positively received... it is just the doing that remains.

> I didn't see a ticket over on the Joomla docker github page for this. This was a conversation in the **CMS Maintainers** team meeting, and it was positively received... it is just the doing that remains.
Member

Hi guys, here is my code to have it working. For PHP 8+ only.

# Install system dependencies required for Xdebug
RUN apt-get update && apt-get install -y \
        git \
        unzip \
    && rm -rf /var/lib/apt/lists/*

# Install Xdebug
RUN pecl install xdebug \
    && docker-php-ext-enable xdebug

# Configure Xdebug (adjust the configuration as needed)
RUN { \
        echo 'zend_extension=xdebug'; \
        echo 'xdebug.mode=debug'; \
        echo 'xdebug.start_with_request=yes'; \
        echo 'xdebug.client_host=host.docker.internal'; \
        echo 'xdebug.client_port=9003'; \
        echo 'xdebug.log=/var/www/html/xdebug.log'; \
    } > /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

in the Dockerfile.joomla obviously

Hi guys, here is my code to have it working. For PHP 8+ only. ``` # Install system dependencies required for Xdebug RUN apt-get update && apt-get install -y \ git \ unzip \ && rm -rf /var/lib/apt/lists/* # Install Xdebug RUN pecl install xdebug \ && docker-php-ext-enable xdebug # Configure Xdebug (adjust the configuration as needed) RUN { \ echo 'zend_extension=xdebug'; \ echo 'xdebug.mode=debug'; \ echo 'xdebug.start_with_request=yes'; \ echo 'xdebug.client_host=host.docker.internal'; \ echo 'xdebug.client_port=9003'; \ echo 'xdebug.log=/var/www/html/xdebug.log'; \ } > /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini ``` in the Dockerfile.joomla obviously
Member

Here is the way for older version up to PHP 7.4

# Install system dependencies required for Xdebug
RUN apt-get update && apt-get install -y \
        git \
        unzip \
        libzip-dev \
    && docker-php-ext-install zip \
    && pecl install xdebug-2.9.8 \
    && docker-php-ext-enable xdebug

# Configure Xdebug
RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.idekey=PHPSTORM" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

I use it for older J3 projects I didn't migrate yet.

Here is the way for older version up to PHP 7.4 ``` # Install system dependencies required for Xdebug RUN apt-get update && apt-get install -y \ git \ unzip \ libzip-dev \ && docker-php-ext-install zip \ && pecl install xdebug-2.9.8 \ && docker-php-ext-enable xdebug # Configure Xdebug RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ && echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ && echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ && echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ && echo "xdebug.idekey=PHPSTORM" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini ``` I use it for older J3 projects I didn't migrate yet.
Author

@vistamedia Are you using that with octojoom? Or just with your own docker images and builds?

@vistamedia Are you using that with octojoom? Or just with your own docker images and builds?
Member

@cpaschen With docker images, I don't use octojoom.

@cpaschen With docker images, I don't use octojoom.
Author

@vistamedia Sorry, one more question, are you using the official Joomla docker images, or the VDM ones or just your own custom built images?

I think I'm finally going to have to sit down and learn how to build my own docker images. Hopefully then I'll be able to more constructively contribute to this ticket, by creating, testing, and offering solution.

@vistamedia Sorry, one more question, are you using the official Joomla docker images, or the VDM ones or just your own custom built images? I think I'm finally going to have to sit down and learn how to build my own docker images. Hopefully then I'll be able to more constructively contribute to this ticket, by creating, testing, and offering solution.
Owner

@cpaschen he is using the official Joomla docker image... in a docker file like this:

# Use Joomla 5 official Docker image as the base
FROM joomla:5-php8.2-apache

# Install required system dependencies for Xdebug
RUN apt-get update && apt-get install -y \
        git \
        unzip \
    && rm -rf /var/lib/apt/lists/*

# Install and enable Xdebug PHP extension
RUN pecl install xdebug \
    && docker-php-ext-enable xdebug

# Configure Xdebug with optimal defaults for debugging
RUN { \
        echo 'zend_extension=xdebug'; \
        echo 'xdebug.mode=debug'; \
        echo 'xdebug.start_with_request=yes'; \
        echo 'xdebug.client_host=host.docker.internal'; \
        echo 'xdebug.client_port=9003'; \
        echo 'xdebug.log=/var/www/html/xdebug.log'; \
    } > /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

# Adjust permissions to ensure Apache can write Xdebug logs
RUN touch /var/www/html/xdebug.log \
    && chown www-data:www-data /var/www/html/xdebug.log

# Define the working directory
WORKDIR /var/www/html

I am working on a set of images that will already have these features in it...

@cpaschen he is using the official Joomla docker image... in a docker file like this: ``` # Use Joomla 5 official Docker image as the base FROM joomla:5-php8.2-apache # Install required system dependencies for Xdebug RUN apt-get update && apt-get install -y \ git \ unzip \ && rm -rf /var/lib/apt/lists/* # Install and enable Xdebug PHP extension RUN pecl install xdebug \ && docker-php-ext-enable xdebug # Configure Xdebug with optimal defaults for debugging RUN { \ echo 'zend_extension=xdebug'; \ echo 'xdebug.mode=debug'; \ echo 'xdebug.start_with_request=yes'; \ echo 'xdebug.client_host=host.docker.internal'; \ echo 'xdebug.client_port=9003'; \ echo 'xdebug.log=/var/www/html/xdebug.log'; \ } > /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini # Adjust permissions to ensure Apache can write Xdebug logs RUN touch /var/www/html/xdebug.log \ && chown www-data:www-data /var/www/html/xdebug.log # Define the working directory WORKDIR /var/www/html ``` I am working on a set of images that will already have these features in it...
Author

Thanks for all that info.
I spent quite a few hours trying to learn all the details of docker, but still run into issues.
So I'm just going to stick with Octojoom (and live with vardump() for debugging when needed).

I must say, Octojoom is WONDERFUL and very stable.

Having xDebug available via octojoom would be nice when you have time.

Thanks for all that info. I spent quite a few hours trying to learn all the details of docker, but still run into issues. So I'm just going to stick with Octojoom (and live with vardump() for debugging when needed). I must say, Octojoom is WONDERFUL and very stable. Having xDebug available via octojoom would be nice when you have time.
Author

Just curious if you had a chance to add xdebug to any Joomla docker images?

Just curious if you had a chance to add xdebug to any Joomla docker images?
Author

(Or add the ability to octojoom to include xdebug)

If not (or even if so), I'd love to learn what method you are using besides xdebug to provide live debugging results when working with Joomla/JCB code.

(Or add the ability to octojoom to include xdebug) If not (or even if so), I'd love to learn what method you are using besides xdebug to provide live debugging results when working with Joomla/JCB code.
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: octoleo/octojoom#14
No description provided.