我正在尝试为 PhpStorm 设置 xdebug。
设置如下:
- Symfony 应用程序在 Docker 容器中
- 我将其用于 REST API 调用
到目前为止我尝试过的:
已安装 Xdebug - reference
RUN pecl install xdebug RUN docker-php-ext-enable xdebug
然后运行命令:
echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /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
echo "xdebug.default_enable = 0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
echo "xdebug.remote_enable = 1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
echo "xdebug.remote_autostart = 0" >> /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.profiler_enable = 0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
echo "xdebug.remote_host = "docker.for.mac.host.internal"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
如下图所示设置 PhpStorm(除了端口是 8090,因为我的 Web 应用程序在该端口上运行。我使用 localhost:8090/
访问本地网站):
现在,当我进行 API 调用时,没有任何反应。它不会在断点处停止。
有人帮我解决这个问题吗?
PS:我正在使用 Xdebug Helper
chrome 插件。
最佳答案
这是我在 Docker LAMP 堆栈中使用的设置
https://github.com/delboy1978uk/lamp
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9001
xdebug.remote_autostart=0
xdebug.remote_connect_back=1
xdebug.idekey="PHPSTORM"
xdebug.max_nesting_level = 250
我用的是PHP-FPM,所以9000端口已经被占了,我改成了9001,试一试,应该可以的!
关于php - 使用 PhpStorm 和 Xdebug 调试 Symfony REST API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51420145/