Xdebug在对类的静态属性的访问中断了
我在开发环境中遇到了Xdebug问题。
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设置:
[xdebug] xdebug.remote_enable=1 xdebug.remote_autostart=0 xdebug.remote_host=172.17.42.1 xdebug.remote_port=9000
一切正常,但一件事。 在debugging代码时:
<?php class A { static private $a; static public function init() { self::$a = 123; } } A::init();
如果我在self::$a = 123;
上设置断点self::$a = 123;
或者走进去,我得到:
Fatal error: Access to undeclared static property: A::$a
如果我没有进入这一行,debugging会话继续没有任何问题。
怎么了?
我认为这是XDebug中的一个错误 – 请参阅这些错误报告
同时你也许可以通过使用xdebug_break()
函数来解决这个问题,就在xdebug_break()
exception的那一行之后,继续从那里debugging。 我试图在抛出exception之后设置一个断点,并且发现断点不足以阻止抛出exception。
不是一个完美的解决scheme,但希望这些错误很快就会得到解决
所描述的错误只能在官方的PHP5图像中复制。 PHP 7的图像工作得很好,当从jessie或ubuntu构build定制的PHP5 FPM图像时,错误也不会发生。