在Mac上为PHPSTORM配置CLI解释器

发布于 2025-01-22 20:47:06 字数 476 浏览 5 评论 0原文

我已经从BRER中安装了PHP,它在VSCODE中工作正常,但是在PHPSTORM中,我无法配置解释器以调试我的PHP代码。 在配置文件中,它说具有红色图标的“未安装”,可执行路径为空。

我正在尝试调试仅代码,而不是网页,因此目前不需要Apache Server或其他。

在终端上执行php -v时,我会得到:

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

告诉我这已正确安装。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的笑 2025-01-29 20:47:06

按照 phpstorm文档这意味着:提供完整的路径)。仅具有php可能还不够。

  1. 打开您的OS终端和类型哪个php(或可以是,其中php;这取决于所使用的OS)。它将显示在该终端中运行php时执行可执行文件的完整路径。

    如果已安装了一个以上的PHP版本,并且想使用非默认PHP安装/版本,则使用该特定版本的路径。

  2. 从那里复制该完整的路径(如果有多个路径,则使用最高或最需要的一条路径),然后在PHPSTORM中的PHP解释器屏幕的“ PHP可执行”字段中使用它。

    phpstorm

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文