如何在 Nginx 上使用 Xdebug 和 Laravel,在 Mac 上使用 PHPStorm?
How to use Xdebug with Laravel on Nginx with PHPStorm on Mac?
有关如何使用 PHPStorm 设置 XDebug 的指南。
版本:
- PHP 7.0
- PHP风暴2016.3.2
- XDebug 2.5
- OS X 埃尔卡皮坦 10.11.6
本指南仅适用于 PHP7、Mac El Capitan、PHPStorm 2016.3
- 安装 brew http://brew.sh/
- 安装php7
brew install php70
安装nginx
指南 - http://learnaholic.me/2012/10/10/installing-nginx-in-mac-os-x-mountain-lion/
配置 - https://gist.github.com/kmaxat/c07795ab88677efb843686d075fafa9e
brew install php70-xdebug
在 laravel 的 public 文件夹中创建 info.php 文件:
info.php: <?php phpinfo();
编辑文件/usr/local/etc/php7.0/conf.d/ext-xdebug.ini
zend_extension="/usr/local/opt/php70-xdebug/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_connect_back=1
xdebug.remote_port = 9001
xdebug.scream=0
xdebug.show_local_vars=1
xdebug.idekey=PHPSTORM
重启nginx sudo nginx -s reload
或brew services restart nginx
重启php-fpmbrew services restart php70
去localhost/info.php,应该可以看到xdebug。部分图片:
- 设置您的 CLI 解释器。 PHPStorm -> 设置 -> 语言和框架 -> PHP
- 单击 CLI 解释器旁边的“...”。如果上述步骤正确完成,您应该能够看到:
- 设置服务器:
运行 -> 编辑配置 -> ...(服务器旁边)。
- 设置编辑配置
运行 -> 编辑配置 -> + -> PHP Web 应用程序。选择创建的服务器,设置名称
- 在工具栏 select 创建服务器,然后点击 "Start Listening for PHP Debug Connections"。
- 在public/index设置断点。php
- 在工具栏中单击 "Debug 'ServerName'"
有关如何使用 PHPStorm 设置 XDebug 的指南。
版本:
- PHP 7.0
- PHP风暴2016.3.2
- XDebug 2.5
- OS X 埃尔卡皮坦 10.11.6
本指南仅适用于 PHP7、Mac El Capitan、PHPStorm 2016.3
- 安装 brew http://brew.sh/
- 安装php7
brew install php70
安装nginx
指南 - http://learnaholic.me/2012/10/10/installing-nginx-in-mac-os-x-mountain-lion/
配置 - https://gist.github.com/kmaxat/c07795ab88677efb843686d075fafa9e
brew install php70-xdebug
在 laravel 的 public 文件夹中创建 info.php 文件:
info.php:
<?php phpinfo();
编辑文件
/usr/local/etc/php7.0/conf.d/ext-xdebug.ini
zend_extension="/usr/local/opt/php70-xdebug/xdebug.so" xdebug.remote_enable = 1 xdebug.remote_connect_back=1 xdebug.remote_port = 9001 xdebug.scream=0 xdebug.show_local_vars=1 xdebug.idekey=PHPSTORM
重启nginx
sudo nginx -s reload
或brew services restart nginx
重启php-fpm
brew services restart php70
去localhost/info.php,应该可以看到xdebug。部分图片:
- 设置您的 CLI 解释器。 PHPStorm -> 设置 -> 语言和框架 -> PHP
- 单击 CLI 解释器旁边的“...”。如果上述步骤正确完成,您应该能够看到:
- 设置服务器: 运行 -> 编辑配置 -> ...(服务器旁边)。
- 设置编辑配置 运行 -> 编辑配置 -> + -> PHP Web 应用程序。选择创建的服务器,设置名称
- 在工具栏 select 创建服务器,然后点击 "Start Listening for PHP Debug Connections"。
- 在public/index设置断点。php
- 在工具栏中单击 "Debug 'ServerName'"