Home » Php » PhpStorm "empty path to php" when setting up project through Composer

PhpStorm "empty path to php" when setting up project through Composer

Posted by: admin July 12, 2020 Leave a comment


I am following along with a Laracast (https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/21?autoplay) and when I try to set up a new Laravel project using Composer, as taught in the tutorial, I am unable to complete the dialog due to an error message stating “Empty path to php”.

I have the path to PHP set properly, and am able to run and debug through PhpStorm. If someone can help me understand what’s going on here, I’d appreciate it. I have searched Google and only found one result, which was for Windows, not Mac. (https://devnet.jetbrains.com/thread/475384)

Screenshot of what I'm seeing

How to&Answers:

As you can see from your screenshot the “New Composer Project” screen does not have any option to select the PHP Interpreter that is required to actually launch composer (that’s how PhpStorm works — the same approach for all supported OS: Linux, Mac and Windows).

The workaround is to choose default PHP Interpreter in Default Settings (settings that would be used for any future new project created on this machine) — this way you will have PHP Interpreter already pre-selected even for this kind of new project.

You need to use File | Default Settings to set such default PHP Interpreter there (well, that’s on Windows/Linux — on Mac it could be at some different location in menu). If you do not have any projects opened you still can access such Default Settings from Welcome screen.

Note: If you are still seeing same error after setting PHP Interpreter, then try restarting PhpStorm — should help.

Note that In current 2016.x versions you can also specify what PHP Interpreter to use (and create new one if needed) at the bottom of this New Project screen — it has Settings section which you can unfold — just scroll the window down a bit to see it.