php: Xdebug breaks on access to class static property
I’ve a problem with xdebug in my dev environment
FROM library/php:5.5-apache
RUN apt-get -qqy update && apt-get -qqy install \
libpq-dev \
libmcrypt-dev \
libxml2-dev \
ssl-cert \
vim \
git \
mc \
&& rm -r /var/lib/apt/lists/*
# compile and add xdebug
RUN pecl install xdebug \
&& echo "zend_extension=xdebug.so" >> "/usr/local/etc/php/conf.d/xdebug.ini"
# configure apache and vhosts
RUN a2enmod rewrite ssl \
&& a2ensite 000-default default-ssl
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_RUN_DIR /var/run/apache2
ENV APACHE_PID_FILE /var/run/apache2/apache2.pid
ENV APACHE_LOCK_DIR /var/lock/apache2
CMD ["apache2-foreground"]
Xdebug settings:
[xdebug]
xdebug.remote_enable=1
xdebug.remote_autostart=0
xdebug.remote_host=172.17.42.1
xdebug.remote_port=9000
Everything works good but one thing. When debbuging code:
<?php
class A {
static private $a;
static public function init() {
self::$a = 123;
}
}
A::init();
If i set breakpoint on self::$a = 123;
or step into the line then i get:
Fatal error: Access to undeclared static property: A::$a
If i don’t step into that line debugging session continous without any problem.
I tried different xdebug versions, different debug clients (PhpStorm and Netbeans), different ways to install xdebug (pecl, compile from source). Nothing worked. I believe there is some problem in the the official image.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 8
- Comments: 39 (2 by maintainers)
Commits related to this issue
- workaround for 'Xdebug breaks on access to class static property' see https://github.com/docker-library/php/issues/133 — committed to alchimik/laradock by alchimik 7 years ago
- workaround for 'Xdebug breaks on access to class static property' (#654) see https://github.com/docker-library/php/issues/133 — committed to laradock/laradock by alchimik 7 years ago
- Xdebug breaks on access to class static property https://github.com/docker-library/php/issues/133 — committed to Kazylla/docker-php by Kazylla 7 years ago
- Workaround for https://github.com/docker-library/php/issues/133 - Xdebug breaks on access to class static property — committed to JeroenBoersma/docker-php by marciowebjump 7 years ago
- Use alternate Xdebug installation method on PHP 5.6 Uses workaround detailed in github.com/docker-library/php/issues/133 to compile Xdebug from source with different args. Allows debugging of code in... — committed to Persata/docker-php-1 by Persata 5 years ago
- Added xdebug manual compile to avoid a bug https://github.com/docker-library/php/issues/133 — committed to inblank/docker-php5.6-apache by inblank 4 years ago
Still had this problem on PHP 5.6.40.
Constructed the following for my Dockerfile (basing off of official PHP image):
Now works. Hope this solution helps someone that wishes to keep using the official PHP images. Saw a comment that it only affects Debian ‘jessie’, but had no luck with ‘stretch’ either 😦
The solution from Wilkolicious worked for me on PHP 5.4.45 and Xdebug 2.4.1 on Debian Jessie, docker image
php:5.4-fpm
. I just replaced2_5_5
with2_4_1
in both places in his instructions.I still needed to do
RUN docker-php-ext-enable xdebug
after theRUN
line he gave.BEFORE
AFTER
If it’s helpful to anyone, I’ve made https://github.com/chrissound/dockercompose_phpapachemysql_ubuntu
You’re able to install Xdebug following vanilla Ubuntu instructions.
The below worked for me:
Previous to this I had:
docker-php-ext-enable xdebug
somewhere in the above.The fix has been committed.
@nei did you try my solution a bit further up?
bingo. Same here .
Looks like this fix pushed to master & php-5.6 branches. I hope it will be included to 5.6.29. https://github.com/php/php-src/commit/1cd566e13f915ccd06a1140d04d4d946748ad021