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 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题