Sublime Text 2使用了错误的PHP版本

我正在尝试测试一个涉及安装在PHP 5.5扩展目录中的模块的类,特别是Couchbase(这是 运行正常,我正在开发它在同一台机器上很好)。 但是当php单元尝试运行测试时给出了一个错误,说找不到类Couchbase,这当然是在php sdk中定义的。 我在MacOSX 10.7.3上。</ p>

当我在终端中运行时</ p>

  tomas:~tomasruiz $ php -v 

NPHP 5.5.8(cli)(建于2014年1月12日19:34:38)
版权所有(c)1997-2013 PHP Group
Zend Engine v2.5.0,版权所有(c)1998-2013 Zend Technologies
with Zend OPcache v7.0.3-dev,版权所有(c)1999-2013,作者:Zend Technologies
,Xdebug v2.2.3,版权所有(c)2002-2013,作者:Derick Rethans

tomas:~tomasruiz $ which php

/ usr / local / php5 / bin / php
</ code> </ pre>

我在Sublime Text 2中创建了一个插件,以查看在sublime文本中使用的php版本</ p>

  import sublime,sublime_plugin 
import subprocess
import os

class ExampleCommand(sublime_plugin.TextCommand):
def run(self,edit):
self.view.window() .run_command('exec',{'cmd':[“php”,“ - v”]})
</ code> </ pre>

这就是它返回的内容...... </ p>

  PHP 5.3.6 with Suhosin-Patch(cli)(内置:2011年9月8日19:34:00)
版权所有(c)1997-2011 PHP Group
Zend 引擎v2.3.0,版权所有 (c)1998-2011 Zend Technologies
与Xdebug v2.1.2,版权所有(c)2002-2011,Derick Rethans
</ code> </ pre>

与上述相同 但是用“哪个php”.. </ p>

  / usr / bin / php 
</ code> </ pre>

有人有任何想法 怎么配置? 或者我在这里做错了什么?</ p>

提前致谢。</ p>

TR </ p>
</ div>

展开原文

原文

I'm trying to test a class which involves a module installed in PHP 5.5 extension directory, specifically Couchbase (which is running ok and I'm developing on top of it just fine in the same machine). But when php unit try to run the tests gives me an error saying the class Couchbase is not found, which is of course defined in the php sdk. I'm on MacOSX 10.7.3.

when I run in my terminal

tomas:~ tomasruiz$ php -v

PHP 5.5.8 (cli) (built: Jan 12 2014 19:34:38) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

tomas:~ tomasruiz$ which php

/usr/local/php5/bin/php

I created a plugin in Sublime Text 2 to see the php version used in sublime Text

import sublime, sublime_plugin
import subprocess
import os

class ExampleCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.window().run_command('exec', {'cmd': ["php", "-v"]})

and this is what it returns...

PHP 5.3.6 with Suhosin-Patch (cli) (built: Sep  8 2011 19:34:00) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
    with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans

and the same thing as above but with "which php" ..

/usr/bin/php

Someone has any idea on how to configure that? or what am I doing wrong here?

Thanks in advance.

TR

1个回答



我假设你的意思是你通过ST构建系统运行php单元? 如果是这样的话我就是如何解决类似的问题</ p>

解决方案1:</ strong>符号链接</ p>

  mv /  usr / bin / php / usr / bin / php53 
ln -s / usr / local / php5 / bin / php / usr / bin / php
</ code> </ pre>

解决方案2:</ strong>为PHP编辑或创建第二个构建系统</ p>

  {“cmd”:[“/ usr / local / php5 / bin / php”,  “$ file”],“file_regex”:“php $”,“selector”:“source.php”} 
</ code> </ pre>

您遇到的问题最多 可能是因为ST运行PHP的用户没有设置为使用 / usr / local / php5 / bin / php </ code>可执行文件,但OS X内置的旧版PHP 5.3为 / usr / bin / </ code>是系统尝试查找可执行文件的下一个地方,如果在本地bin目录中找不到它。</ p>

我建议使用解决方案1 将确保您系统上的所有内容都使用正确的PHP版本。</ p>
</ div>

展开原文

原文

I assume you mean you're running php unit through ST build system? If that's so here's how I managed to fix a similar problem

Solution 1: Symlink

mv /usr/bin/php /usr/bin/php53
ln -s /usr/local/php5/bin/php /usr/bin/php

Solution 2: Edit or create a second build system for PHP

{ “cmd”: [“/usr/local/php5/bin/php”, “$file”], “file_regex”: “php$”, “selector”: “source.php” }

The problem you're facing is most likely caused by that the user under which ST runs PHP is not set up to use /usr/local/php5/bin/php executable, but the OS X built in old PHP 5.3 as /usr/bin/ is the next place where system tries to find the executable, if it's not found in a local bin directory.

I suggest using solution 1 as that way you will be sure everything on your system is using the correct PHP version.

duanmajing9332
duanmajing9332 如果您需要旧版本,这很粗糙,您可以尝试从Sublime .py脚本运行'echo'$ USER“'bash命令
6 年多之前 回复
dongnue4923
dongnue4923 谢谢@Vlakarados,我会尝试解决方案1,但这是一个有点粗略的解决方案。 你是什​​么意思“ST运行PHP的用户没有设置为使用/ usr / local / php5 / bin / php可执行文件”,有没有办法知道用户在使用什么? 或改变它的方法?
6 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问