Installing xdebug with laravel valet and php 7.2 on Mac, and linking with PHPStorm
- Install or update Homebrew to the latest version
2. Install PHP 7.2
brew install firstname.lastname@example.org.
Make sure Mac is using the lastest version of php which you installed using homebrew.
php -v should show
PHP 7.2.11 (cli) (built: Oct 11 2018 16:23:09) ( NTS )
Copyright © 1997–2018 The PHP Group
Zend Engine v3.2.0, Copyright © 1998–2018 Zend Technologies
with Xdebug v2.6.1, Copyright © 2002–2018, by Derick Rethans
with Zend OPcache v7.2.11, Copyright © 1999–2018, by Zend Technologies
3. Install the xdebug
pecl install xdebug . You won’t be able to install xdebug using homebrew.
php -m is showing Xdebug in [Zend Modules] and xdebug in [PHP Modules].
4. Edit the xdebug settings in php.ini
Find the path of php using
which php . For me it was
/usr/local/bin/php, so will use it next, replace it with your path for next commands.
cd /usr/local/bin/php/7.2/conf.d and edit
ext-xdebug.ini file, it its not available, create it and paste following in it.
php -i | grep xdebug and verify that xdebug variables whcih you mentioned above are reflecting the correct values.
5. Rest of Valet installation.
If valet is already installed, restart it.
Install Valet with Composer via
composer global require laravel/valet. Make sure the
~/.composer/vendor/bin directory is in your system's "PATH".
valet install command. This will configure and install Valet and DnsMasq, and register Valet's daemon to launch when your system starts.
Sometimes the order of valet installation is also important. For example if you first installed valet, and then updated php or its settings, it might not pick up things. So you might have to uninstall the valet and re-install according to the order given in article.
6. Linking with PHPStorm
Open PHPStorm, goto
preferences => Lanuages & Frameworks => PHP => Debug and make all settings like this screen.
preferences => Lanuages & Frameworks => PHP => Debug => DBGp Proxy and make all settings like this screen.
7. DEBUG — YEEEAAAHHHH
Add a breakpoint somewhere, and open the valet based *.test url. It should auto stop breakpoint. No need to provide XDEBUG_PHPSTORM keys or installing xdebug extensions.