Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 522
max Avatar asked Feb 01 '17 09:02

max


People also ask

Why is Xdebug not working?

When the debugger cannot connect or refuses the connection, check the following: Make sure Xdebug or Zend Debugger are configured to connect to the host and port PhpStorm is running on. In the Xdebug configuration, make sure xdebug. remote_host and xdebug.


1 Answers

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'"
like image 101
max Avatar answered Oct 09 '22 22:10

max