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.

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

报告相同问题?

悬赏问题

  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含