Sublime Text 3的构建系统执行不同版本的PHP [英] Build system of Sublime Text 3 executes a different version of PHP
问题描述
我在OSX上使用SublimeText3.问题是:
I am using SublimeText3 on OSX. The problem is:
- 如果我在 SublimeText3 上执行 PHP 脚本,那么它会由 PHP 5.5 执行.
- 但是,如果我从外壳程序(iTerm)执行相同的脚本,那么它将由PHP 7执行.
如何在SublimeText3上使用PHP7执行脚本?
How can I execute a script with PHP7 on SublimeText3?
构建系统正在关注.
{
"cmd" : ["php", "$file"],
"file_regex": "php$",
"selector" : "source.php"
}
PHP脚本只是:
<?php
phpinfo();
?>
推荐答案
指定命令(cmd)的绝对路径.
Specify the absolute path to the command (cmd).
假设 $ file
是/path/to/file
,则命令 ['php',"$ file"]
展开到 php/path/to/file
.就像在命令行上运行以下命令一样:
Let's say $file
is /path/to/file
, then the command ['php', "$file"]
expands to php /path/to/file
. This is like running the following on the command line:
$ php /path/to/file
因为命令( php
)是相对的,所以搜索系统路径(在Linux上,系统路径在环境变量 PATH
中)以找到 php
.
Because the command (php
) is relative, the system path (on linux the system path is in the environment variable PATH
) is searched to find php
.
您可以为命令指定绝对路径.假设您安装了以下版本:
You can specify an absolute path for the command. Let's say you have the following versions installed:
- /path/to/php/versions/7.0.0/bin/php
- /path/to/php/versions/5.5.0/bin/php
然后,您可以配置命令以使用v7.0.0:
Then you can configure a command to use v7.0.0:
{
"cmd" : ["/path/to/php/versions/7.0.0/bin/php", "$file"],
"file_regex": "php$",
"selector" : "source.php"
}
和v5.5.0:
{
"cmd" : ["/path/to/php/versions/5.5.0/bin/php", "$file"],
"file_regex": "php$",
"selector" : "source.php"
}
依此类推...
这篇关于Sublime Text 3的构建系统执行不同版本的PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!