How to configure PhpStorm to use Laravel Herd's PHP
Important: The information in this article is over 12 months old, and may be out of date or no longer relevant.
But hey, you're here anyway, so give it a read see if it still applies to you.
If you’ve been developing with Laravel on macOS, you may be like me and be a Valet user. Which is awesome and works great – until it doesn’t (i.e. homebrew throws a wobbly for some reason). At LaraconUS in July 2023, Laravel Herd was announced, which is similar to Valet, but comes with pre-compiled PHP versions, a handy macOS app, and doesn’t use homebrew.
Switching from Valet to Herd is straight forward too – and even migrates your existing Valet configuration, and sucks in your platform’s Expose credentials too. Neat.
After Herd was up and running, I removed Valet (and its PHP versions), and went to run a test in PhpStorm. But uh oh, PhpStorm now can’t find PHP – your path to PHP may have been something like /opt/homebrew/bin/php
, but if you’ve removed your homebrew versions of PHP, that’s gone. So now what?
No worries, we just need to update the PhpStorm configuration to Herd’s PHP binaries.
But one issue. Where is that? Herd comes with its PHP versions pre-compiled… so where do they live?
Now this is all so totally obvious… but also one of those “oh duh it’s that simple” things that someone else may sit there and not see the forest for the trees. Or the PHP binary for the… uh… files? Anyway…
Two things to do:
Figure out where Herd’s PHP binary is, and
Update PhpStorm
Cool, we can do this.
But which PHP binary… which indeed! We can run which php
in your terminal and boom, we get the path to PHP. It’ll look something like this:
/Users/Marty/Library/Application Support/Herd/bin/php
Note, that’s my path though… unless your name is Marty, it’s unlikely you’ve got the same username as your macOS account.
But hey, that was easy, right? And yes, so totally obvious. Copy that to your clipboard.
Let’s jump back to PhpStorm and pop open the settings - Cmd + , (yep, that’s Command and the comma key) or from the PhpStorm menu, and select PHP on the tree on the left.
Look at your CLI Interpreter, and go for the three dots to the right of the dropdown.
Paste in your copied path from before, and PhpStorm should update and read your php.ini for Herd too.
Click OK, and OK again, and you’re ready to go! If you're having a daft moment like me, this may be enough to restart those brain neurons.