dongmen9517 2014-02-14 01:05
浏览 95
已采纳

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

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条回答 默认 最新

  • doudang1890 2014-02-14 13:49
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!