php - 设置包括 PEAR on Wamp 的路径

标签 php windows wamp pear include-path

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

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

然后,我创建了测试:

<?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);
?>

我在 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"

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

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

在 Windows XP 和 WAMP 中工作。

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

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

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

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

最佳答案

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

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

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

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

关于php - 设置包括 PEAR on Wamp 的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8112866/

相关文章:

php - 让 PHP 在 64 位操作系统中访问 32 位 COM 对象

php - 子查询返回多于 1 行错误

c++ - 如何防止 IE 在打开文本文件时显示 "Internet Explorer restricted this webpage from running scripts ..."消息?

php - Eclipse 输出到 WAMP 网络服务器 www 文件夹

wamp服务器无法在8.1上运行

php - 在 php 中从 mysql 格式化日期时间

php - 用于在第 1 行的 WHERE 1=0' 附近使用正确语法的 MySQL 服务器版本

python - 如何使用 python opencv2 在 Windows 中的图像上写入文本

windows - 将 virtualenvwrapper 环境从 ubuntu 转移到 windows

java - 传递 Java 函数作为参数和类型检查响应