First, assuming you have installed valet:
pecl install xdebug
Next, find which files are loaded by the PHP installation:
php --ini
$ php --ini
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
/usr/local/etc/php/7.4/conf.d/error_log.ini,
/usr/local/etc/php/7.4/conf.d/ext-opcache.ini,
/usr/local/etc/php/7.4/conf.d/php-memory-limits.ini
Create a new file 99-xdebug.ini in the Scan for additional.ini files in folder, i.e. /usr/local/etc/php/7.4/conf.d:
xdebug.mode = "develop,debug"
xdebug.client_host = "localhost"
xdebug.client_port = "9003"
xdebug.idekey = "phpstorm"
xdebug.start_with_request = "yes"
Then restart valet, valet restart.
I’ve added this to my .zshrc and effortless changes without having to remember the path and to reset valet for the config changes to be reloaded.
function xdebug
{
nano /usr/local/etc/php/7.4/conf.d/99-xdebug.ini; valet restart
}
Configuring PHPStorm
Go to preferences -> PHP.
I like to uncheck the two Force break.. checkboxes and set the Debug port to 9003 only (since I have port 9000 in use already for Graylog).

Go to Run -> Edit configurations.

Attach new remote PHP.

Give a suitable name and IDE key.
