Using PHP as CLI Interpreter in PhpStorm

Issue Summary

I would like to use the version of PHP tied to the site in LocalWP in PhpStorm as the CLI Interpreter for things like Composer and PHPUnit.

If I open the shell, run which php, and then paste that URL into PhpStorm for the interpreter it almost works. It finds the executable alright, but it cannot find the corresponding ini file.

It seems like a symlink or something like that could resolve the issue. :thinking:

System Details

  • Which version of Local is being used? 6.1.8

  • What Operating System (OS) and OS version is being used?

    • macOS Monterey

Oh. Turns out it really was as simple as creating a symlink to the ini file where the php executable is located. Hahah!

Steps

  1. Open up the shell for the site
  2. Run which php
  3. Copy that URL and paste it into PhpStorm for the executable path
  4. Run php -i in the terminal
  5. At the top of the output, grab the ini configuration path
  6. In a separate terminal (not in the Local shell) cd to the directory where the php file is located
  7. Run ln -s /path/to/php.ini php.in — using the php.ini path from above
  8. :boom:
1 Like

I don’t use PHPStorm, so forgive my ignorance!

Does PHPStorm store a project configuration file somewhere similar to how VS Code has a project config folder named .vscode in the project root?

I’m guessing there is something like that and is what the Xdebug PHPStorm addon uses when adding the run configuration for PHPStorm.

@jasontheadams Have you tried using that addon to see if it’s basically doing the same thing that your shell wizardry is doing?

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.

@jasontheadams – messaged me since this topic closed after being solved:

I tried using that add-on on another install, but it doesn’t appear to have added a PHP Interpreter to PhpStorm.