PEAR on Windows: How to change pear.ini location
Solution 1
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
Solution 2
Another way is edit your windows system environment and add PHP_PEAR_SYSCONF_DIR variable pointing to php's dir.
Solution 3
To change the path from c:\windows\pear.ini
to c:\path_to_xampp\php\pear.ini
you can download this file at http://pear.php.net/go-pear.phar and place it in your c:\path_to_xampp\php
folder.
Run:
php go-pear.phar
Change the location of your pear.ini (11) to c:\path_to_xampp\php
($prefix\pear.ini
).
Save and run the new file c:\path_to_xampp\php\PEAR_ENV.reg
.
Log out of Windows and run (in c:\path_to_xampp\php
)
pear config-show
Now you can see that the path has been updated :)
Solution 4
In windows 7 i use powershell.
you can set the PHP_PEAR_SYSCONF_DIR variable and then run a pear command. For Example:
$env:PEAR_CONFIG_SYSCONFDIR = 'c:\path_to_xampp\php'
pear install pear.phpunit.de/PHPUnit
Related videos on Youtube
Pekka
Self-employed web developer and graphic designer. After-hours artist. Working from an old off-the-grid house in the Canary Islands. Not doing much here any more because the Stack Overflow I wish to build and participate in is no longer supported and the company running it has started going down a path of incomprehensible, increasingly outright evil actions. E-Mail: first name at gmx dot de
Updated on August 03, 2020Comments
-
Pekka over 3 years
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
c:\windows\pear.ini
instead of the existingc:\path_to_xampp\php\pear.ini
. This results (rightly) in apermission denied
error. I am logged on as Administrator, but the Windows directory enjoys some additional protection IIRC.Rather than fiddle with write rights in the windows directory, I would like to use the existing pear.ini file.
Does anybody know where to change PEAR's behaviour accordingly?
-
Pekka about 14 yearsCheers Volker!
PHP_PEAR_SYSCONF_DIR
it is. -
hashchange about 12 yearsWorks beautifully for a global PEAR install. But if there are multiple local PEARs, you need to patch pear.bat. See here for more: stackoverflow.com/a/10219809/508355
-
jamesvl almost 12 yearsOn Windows, edit your pear.bat to have the line
IF "%PHP_PEAR_SYSCONF_DIR%"=="" SET "PHP_PEAR_SYSCONF_DIR=c:\dev\php"
(or pointing to wherever your PHP installation actually is) -
VonC over 9 yearsYour question stackoverflow.com/questions/27434425/… could have benefited other. No need to delete it.