简体   繁体   中英

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

Guide on how to setup XDebug with PHPStorm.

Versions:

  • PHP 7.0
  • PHPStorm 2016.3.2
  • XDebug 2.5
  • OS X El Capitan 10.11.6

This guide is only for PHP7, Mac El Capitan, PHPStorm 2016.3

  1. Install brew http://brew.sh/
  2. Install php7 brew install php70
  3. Install nginx

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

    Config - https://gist.github.com/kmaxat/c07795ab88677efb843686d075fafa9e

  4. brew install php70-xdebug

  5. Create info.php file in public folder of laravel:

    info.php: <?php phpinfo();

  6. Edit file /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. Restart nginx sudo nginx -s reload or brew services restart nginx

  8. Restart php-fpm brew services restart php70

  9. Go to localhost/info.php, you should be able to see xdebug. Part of the image:

项目清单

  1. Setup your CLI interpreter. PHPStorm -> Settings -> Languages & Frameworks -> PHP

在此输入图像描述

  1. Click on '...' next to CLI interpreter. If above steps are done properly, you should be able to see this:

在此输入图像描述

  1. Setup Server: Run -> Edit Configurations -> ... (next to server).

在此输入图像描述

  1. Setup Edit configuration Run -> Edit Configurations -> + -> PHP Web Application. Choose created server, set name

在此输入图像描述

  1. In Toolbar select created sever, then click on "Start Listening for PHP Debug Connections".

在此输入图像描述

  1. Set breakpoint at public/index.php

在此输入图像描述

  1. In toolbar click "Debug 'ServerName'"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM