Search code examples
phplaravelnginxphpstormxdebug

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

Solution

  • 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:

    List item

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

    enter image description here

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

    enter image description here

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

    enter image description here

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

    enter image description here

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

    enter image description here

    1. Set breakpoint at public/index.php

    enter image description here

    1. In toolbar click "Debug 'ServerName'"