且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Windows 上的 PEAR:如何更改 pear.ini 位置

更新时间:2022-12-04 20:00:06

不完全确定,但 PEAR 在我机器的注册表中注册了以下项

Not entirely sure but PEAR registered the following keys in the registry of my machine

REGEDIT4
[HKEY_CURRENT_USER\Environment]
"PHP_PEAR_SYSCONF_DIR"="D:\\webserver\\xampp\\php"
....

而 PEAR/Config.php 包含以下代码片段:

And PEAR/Config.php contains the following code snippet:

if (getenv('PHP_PEAR_SYSCONF_DIR')) {
    define('PEAR_CONFIG_SYSCONFDIR', getenv('PHP_PEAR_SYSCONF_DIR'));

和 Config 类的构造函数

and the constructor for the Config class

function PEAR_Config($user_file = '', $system_file = '', $ftp_file = false,
                         $strict = true)
    {
        $this->PEAR();
        PEAR_Installer_Role::initializeConfig($this);
        $sl = DIRECTORY_SEPARATOR;
        if (empty($user_file)) {
            if (OS_WINDOWS) {
                $user_file = PEAR_CONFIG_SYSCONFDIR . $sl . 'pear.ini';
            } else {
                $user_file = getenv('HOME') . $sl . '.pearrc';
            }
        }

$user_file = PEAR_CONFIG_SYSCONFDIR .$sl .'pear.ini'; 似乎是使我的"PEAR 安装使用文件 D:\webserver\xampp\php\pear.ini 的行.
如果那是正确的,您所要做的就是以某种方式设置环境变量 PEAR_CONFIG_SYSCONFDIR

$user_file = PEAR_CONFIG_SYSCONFDIR . $sl . 'pear.ini'; seems to be the line that makes "my" PEAR installation use the file D:\webserver\xampp\php\pear.ini.
If that's correct all you have to do is to somehow set the environment variable PEAR_CONFIG_SYSCONFDIR