如何在 Nginx 上使用 Xdebug 和 Laravel,在 Mac 上使用 PHPStorm?

How to use Xdebug with Laravel on Nginx with PHPStorm on Mac?

有关如何使用 PHPStorm 设置 XDebug 的指南。

版本:

本指南仅适用于 PHP7、Mac El Capitan、PHPStorm 2016.3

  1. 安装 brew http://brew.sh/
  2. 安装php7brew install php70
  3. 安装nginx

    指南 - http://learnaholic.me/2012/10/10/installing-nginx-in-mac-os-x-mountain-lion/

    配置 - https://gist.github.com/kmaxat/c07795ab88677efb843686d075fafa9e

  4. brew install php70-xdebug

  5. 在 laravel 的 public 文件夹中创建 info.php 文件:

    info.php: <?php phpinfo();

  6. 编辑文件/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

  7. 重启nginx sudo nginx -s reloadbrew services restart nginx

  8. 重启php-fpmbrew services restart php70

  9. 去localhost/info.php,应该可以看到xdebug。部分图片:

  1. 设置您的 CLI 解释器。 PHPStorm -> 设置 -> 语言和框架 -> PHP

  1. 单击 CLI 解释器旁边的“...”。如果上述步骤正确完成,您应该能够看到:

  1. 设置服务器: 运行 -> 编辑配置 -> ...(服务器旁边)。

  1. 设置编辑配置 运行 -> 编辑配置 -> + -> PHP Web 应用程序。选择创建的服务器,设置名称

  1. 在工具栏 select 创建服务器,然后点击 "Start Listening for PHP Debug Connections"。

  1. 在public/index设置断点。php

  1. 在工具栏中单击 "Debug 'ServerName'"