Search code examples
phpphpstormconfigure

Configure CLI interpreter for PhpStorm on Mac


I have installed PHP from brew and it works just fine in VSCode, but in PhpStorm I am not able to configure the interpreter in order to debug my PHP code. In the configuration file, it says "PHP not installed" with a red icon, and the executable path is empty.

I am trying to debug just code, not a web page, so there is no need of Apache Server or other for now.

When executing php -v on terminal, I get:

PHP 8.0.17 (cli) (built: Apr  5 2022 22:43:04) ( NTS ) Copyright (c)
The PHP Group Zend Engine v4.0.17, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.17, Copyright (c), by Zend Technologies

which tells me that this installed correctly.


Solution

  • As per PhpStorm documentation you have to point to PHP executable there (which means: provide the full path). Just having php may not be enough.

    1. Open your OS terminal and type which php (or it could be where php; this depends on the OS used). It will show the full path to the executable that gets executed when you run php in that terminal.

      path

      If you have more than one PHP version installed and want to use non-default PHP installation/version then use the path for that specific version.

    2. Copy that full path from there (if there are more than one path then use the top most or the most desired one) and use it in the "PHP executable" field of the PHP Interpreters screen in PhpStorm.

      PhpStorm config