Setup Xdebug3 with PHP7.4, PHPStorm and Laravel Valet

This walkthru assumes that you have Laravel Valet, PHP7.4 installed. If not, follow these instructions.

Install Xdebug

Let’s see what we got so far:

Your output should look something like this:

Configuration File (php.ini) Path: /usr/local/etc/php/7.4
Loaded Configuration File:         /usr/local/etc/php/7.4/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.4/conf.d
Additional .ini files parsed:      /usr/local/etc/php/7.4/conf.d/ext-opcache.ini,
/usr/local/etc/php/7.4/conf.d/php-memory-limits.ini
[xdebug]
zend_extension="xdebug.so" <-- Most likely already there
xdebug.mode=debug
xdebug.client_port="9003"

Please not that the new default port for Xdebug3 is 9003.

Important:
Restart Laravel Valet again.

valet restart

PHPStorm

Next we are going to configure PHPStorm 2020.3 to listen for Xdebug.

Open PHPStorm settings (cmd-,) and check your settings settings.

Languages & Frameworks > PHP > Debug

Make sure Xdebug is listening to port 9003 and ”Can accept external connections” is checked. I like these ones:

Working

Click ”Start listening for debug connections”

Working

Add a breakpoint and reload your page and it should hopefullt work :-)

Working

Profit!

Troubleshooting

Nothing happens

Working

Stops working after an update

If you get similar errors:

Cannot load Xdebug - it was already loaded

Check if your php.ini-file contains zend_extension="xdebug.so" remove this line. The PECL-installer can somethimes add this during upgrades.