在 Mac OS X 上安装带 XAMPP 的 PHPUnit
有谁知道如何在 Mac OS X 上安装 PHPUnit(我使用的是 XAMPP)。我尝试了以下命令,它说安装成功(没有错误)。现在,当我尝试在终端中运行 phpunit 命令时,出现错误,提示找不到命令 phpunit。另外,运行“which phpunit”不会返回任何内容。
我运行的命令:
$sudo /Applications/XAMPP/xamppfiles/bin/pear channel-discover pear.phpunit.de
$sudo /Applications/XAMPP/xamppfiles/bin/pear channel-discover pear.symfony-project.com
$sudo /Applications/XAMPP/xamppfiles/bin/pear channel-discover components.ez.no
$sudo /Applications/XAMPP/xamppfiles/bin/pear install -a phpunit/PHPUnit
谢谢。
Does anyone know how to install PHPUnit on Mac OS X (I'm using XAMPP). I tried the following commands and it said installation succeeded (no errors). Now, when I try to run a phpunit command in Terminal, I get an error that the command phpunit could not be found. Also, running "which phpunit" returns nothing.
The commands I ran:
$sudo /Applications/XAMPP/xamppfiles/bin/pear channel-discover pear.phpunit.de
$sudo /Applications/XAMPP/xamppfiles/bin/pear channel-discover pear.symfony-project.com
$sudo /Applications/XAMPP/xamppfiles/bin/pear channel-discover components.ez.no
$sudo /Applications/XAMPP/xamppfiles/bin/pear install -a phpunit/PHPUnit
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
通过 XAMPP 安装 PHPunit 几乎让我发疯,一个错误告诉我我的 xdebug 版本太旧,无法安装 PHPunit 所需的 Coverage lib,三秒后另一个错误告诉我一切都很好,但没有安装 phpunit 命令。
我选择通过在系统级别(XAMPP 之外)安装 phpunit 来绕过该问题。
这应该安装 pear (并告诉你在哪里,默认是在你家里)。
./phpunit 现在应该返回一些东西(在我的例子中,它显示一些未满足的导入。
如果您没有 /etc/php.ini,请创建它:
然后编辑 /etc/php.ini 并设置正确的路径:
然后在你的 pear bin 目录中调用 ./phpunit 应该可以工作...与 Ubuntu 上的一些 aptitude 和 pear 调用相比,这是相当痛苦的,但它可以让你在 OSX 上工作,你应该仍然可以使用 XAMPP 作为网络服务器。但请记住XAMPP 使用其内置 PHP 环境,phpunit 将使用您的系统之一。
Installing PHPunit through XAMPP almost drove me mad, an error was telling me that my xdebug version was to old to install the Coverage lib required for PHPunit, three seconds later another was telling me that everything was fine but no phpunit command was installed.
I've chosen to bypass that problem by installing phpunit at system level (outside of XAMPP).
This should install pear (and tell you where, default is in your home).
./phpunit should now return you something (in my case it's displaying that some import where unmet.
If you don't have a /etc/php.ini, create it:
Then edit /etc/php.ini and set the right path:
Then calling ./phpunit in your pear bin directory should work... It's quite a pain comparing to a few aptitude and pear call on Ubuntu, but it let you work on OSX. You should be able to still use XAMPP as a webserver but remember that XAMPP uses its buildin PHP environment, phpunit will use the one of your system.
AsTeR 的方法对我有用,因为使用旧的 PHP 5.3.1 当前 PHPUnit 版本会抱怨,因为缺少函数 stream_resolve_include_path 。
所以我最终将解决方案与这个答案一起使用: https://stackoverflow.com/a/8249291
AsTeR's method worked for me though because being stuck with old PHP 5.3.1 current PHPUnit versions will complain because function stream_resolve_include_path is missing.
So I ended up used the solution together with this answer: https://stackoverflow.com/a/8249291
我按照@trent-scott 的做法做了,并得到了同样的错误。
您可以注意到有一个空的包含路径 (include_path='.:')..
转到您的 php.ini 文件。通过在终端“php --ini”中执行此操作来找出哪个。
确保文件中的某处有与此类似的内容(请务必替换用户名):
它应该足够了,但由于某种原因我得到了这个(请务必替换用户名):
I did as @trent-scott did and got same error.
As you can notice there is an empty include path (include_path='.:')..
Go to your php.ini file. Figure out which by doing this in terminal 'php --ini'.
Make sure you've got something similar to this somewhere in the file (be sure to replace username):
It should be sufficient, but I for some reason got this (be sure to replace username):
我资助了另一个对我有用的临时解决方案。不要直接在 Xampp 应用程序中使用 pear 命令,而是尝试使用 pear 可执行文件的完整路径,例如: /Applications/XAMPP/xamppfiles/bin/pear
希望它有所帮助。
I fund an other temporary solution that worked for me. Instead of using the pear command directly within your Xampp app, try using the full path to pear executable like : /Applications/XAMPP/xamppfiles/bin/pear
hope it helped.