windows 设置包括 Wamp 上 PEAR 的路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8112866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 18:27:41  来源:igfitidea点击:

Setup include path for PEAR on Wamp

phpwindowswamppearinclude-path

提问by B Seven

Installed PEAR and followed the directions on http://www.phpunit.de/manual/current/en/installation.html:

安装 PEAR 并按照http://www.phpunit.de/manual/current/en/installation.html 上的说明进行操作

pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit.

Then, I created the test:

然后,我创建了测试:

<?php
# error reporting
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

# include TestRunner
require_once 'PHPUnit/TextUI/TestRunner.php';

# our test class
class ExampleTest extends PHPUnit_Framework_TestCase
{
    public function testOne()
    {
        $this->assertTrue(FALSE);
    }
}

# run the test
$suite = new PHPUnit_Framework_TestSuite('ExampleTest');
PHPUnit_TextUI_TestRunner::run($suite);
?>

I included the following in php.ini file and restarted Apache:

我在 php.ini 文件中包含以下内容并重新启动 Apache:

include_path = ".;C:\Program Files/wamp/bin/php/php5.3.8"
include_path = ".;C:\Program Files/wamp/bin/php/php5.3.8/pear"
include_path = ".;C:\Program Files/wamp/bin/php/php5.3.8/pear/PHPUnit"

I get Warning: require_once(PHPUnit/TextUI/TestRunner.php) [function.require-once]: failed to open stream: No such file or directory in ...

我得到 Warning: require_once(PHPUnit/TextUI/TestRunner.php) [function.require-once]: failed to open stream: No such file or directory in ...

Why doesn't the include path work? Is it because there is a space in Program files?

为什么包含路径不起作用?是因为里面有空格Program files吗?

Working in Windows XP and WAMP.

在 Windows XP 和 WAMP 中工作。

EDIT: I updated the path as suggested.

编辑:我按照建议更新了路径。

The output of echo ini_get('include_path');before require_once call is:

echo ini_get('include_path');在 require_once 调用之前的输出是:

.;C:\Program Files/wamp/bin/php/php5.3.8/pear

Also, removing the require_once command throws Fatal error: Class 'PHPUnit_Framework_TestCase' not found in...

此外,删除 require_once 命令会抛出 Fatal error: Class 'PHPUnit_Framework_TestCase' not found in...

采纳答案by Laith Shadeed

By adding those three lines to the ini, the last one will override everything. Only use this one

通过将这三行添加到 ini,最后一行将覆盖所有内容。只用这个

include_path = ".;C:\Program Files\wamp\bin\php\php5.3.8\pear"

Edit: adding @Gordon comment. We need to keep \pear. Because inner pear libraries are assuming that pear already in the include path.

编辑:添加@Gordon 评论。我们需要保持\pear. 因为内部梨库假设梨已经在包含路径中。

http://pear.php.net/manual/en/installation.checking.php#installation.checking.cli.modifyingphpini

http://pear.php.net/manual/en/installation.checking.php#installation.checking.cli.modifyingphpini