【问题标题】:Run phpsh with specific php script使用特定的 php 脚本运行 phpsh
【发布时间】:2013-10-14 17:46:52
【问题描述】:

默认phpsh使用系统默认的PHP,我的系统是/usr/local/bin/php,即php 5.2。如何使用我的自定义 php 路径 - /srv/bin/php 运行 phpsh?

【问题讨论】:

    标签: phpsh


    【解决方案1】:

    默认不支持,但是可以快速添加。

    通过将此补丁应用到 src 文件夹中的 phpsh.py 来实现:

    --- phpsh.py     2011-05-13 18:16:32.000000000 -0400
    +++ phpsh.py    2013-12-05 14:50:11.906673382 -0500
    @@ -253,6 +253,7 @@
         def __init__(self):
             self.config = ConfigParser.RawConfigParser({
                 "UndefinedFunctionCheck": "yes",
    +            "PathToBinary"    : None,
                 "Xdebug"          : None,
                 "DebugClient"     : "emacs",
                 "ClientTimeout"   : 60,
    @@ -388,6 +389,8 @@
             except Exception, msg:
                self.print_error("Failed to load config file, using default "\
                                 "settings: " + str(msg))
    +       if self.config.get_option("General", "PathToBinary"):
    +           os.environ['PATH'] = self.config.get_option("General", "PathToBinary") + ':' + os.environ['PATH']
             if self.with_xdebug:
                 xdebug = self.config.get_option("Debugging", "Xdebug")
                 if xdebug and xdebug != "yes":
    

    如果您想修改已安装的版本,请找到您的 pythons 站点页面文件夹并在该文件夹中的 init.py 和 phpsh.py 上应用补丁。

    这将在 phpsh/config 中添加一个新的配置变量(如果以 root 身份安装,则在 /etc/phpsh/config 中,如果以用户身份安装,则在 ~/.phpsh/config 中)。在那里你可以指定你的 php 二进制文件的路径

    PathToBinary: /srv/bin
    

    这只是应该找到二进制文件的路径,不是二进制文件本身的路径,即 /srv/bin/php 将不起作用。

    【讨论】:

      猜你喜欢
      • 2016-08-17
      • 2020-10-24
      • 2017-07-05
      • 2015-09-28
      • 1970-01-01
      • 2013-01-26
      • 2016-10-03
      • 2011-07-05
      • 1970-01-01
      相关资源
      最近更新 更多