PEAR on Windows: How to change pear.ini location

前端 未结 5 1490
闹比i
闹比i 2021-02-07 00:44

I am trying to install a PEAR package into my recent XAMPP PHP installation (PHP 5.3.1) on Windows 7 64-bit.

Installing new packages fails because PEAR tries to access <

5条回答
  •  独厮守ぢ
    2021-02-07 01:14

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

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

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

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

提交回复
热议问题