Setup include path for PEAR on Wamp

眉间皱痕 提交于 2019-12-01 05:49:34

问题


Installed PEAR and followed the directions on 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:

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 ...

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

Working in Windows XP and WAMP.

EDIT: I updated the path as suggested.

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

.;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...


回答1:


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

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.

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



来源:https://stackoverflow.com/questions/8112866/setup-include-path-for-pear-on-wamp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!