Jak*_*zyk 15 php xdebug docker
我在开发环境中遇到了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"]
Run Code Online (Sandbox Code Playgroud)
Xdebug设置:
[xdebug]
xdebug.remote_enable=1
xdebug.remote_autostart=0
xdebug.remote_host=172.17.42.1
xdebug.remote_port=9000
Run Code Online (Sandbox Code Playgroud)
一切都很好但只有一件事.调试代码时:
<?php
class A {
static private $a;
static public function init() {
self::$a = 123;
}
}
A::init();
Run Code Online (Sandbox Code Playgroud)
如果我设置断点self::$a = 123;或进入该行,我得到:
Fatal error: Access to undeclared static property: A::$a
Run Code Online (Sandbox Code Playgroud)
如果我没有进入该行,则调试会话将继续进行而不会出现任何问题.
怎么了?
我认为这是 XDebug 中某个地方的错误 - 请参阅这些错误报告
同时,您可以通过在xdebug_break()抛出异常的行之后使用该函数来解决该问题,并从那里继续调试。我尝试在抛出异常后在行上设置断点,我发现一个断点不足以阻止它抛出异常。
不是一个完美的解决方案,但希望这些错误很快就会得到修复。
更新:该问题已被确定为特定版本的 PHP 与特定版本的 Xdebug 以及用于某些图像的特定编译器的组合。docker-library 错误报告中提出了一个潜在的解决方案,如果您使用的是 Docker,它涉及安装这些包的特定版本。
FROM php:5.6.3-apache
# XDebug
RUN yes | pecl install xdebug \
&& yes | apt-get update \
&& yes | apt-get install php5-xdebug \
&& echo "zend_extension=/usr/lib/php5/20131226/xdebug.so" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1351 次 |
| 最近记录: |