Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PEAR on Windows: How to change pear.ini location

Tags:

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 existing c:\path_to_xampp\php\pear.ini. This results (rightly) in a permission 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?

like image 342
Pekka Avatar asked Feb 01 '10 21:02

Pekka


People also ask

How do I know if PEAR is installed on Windows?

Open the file in your browser as http://localhost/check_php.php , to verify the include_path your web server is using. In every case, PEAR's php_dir should be in the include path. If not, add it in your system's php.

How do I know if PEAR Mail is installed?

Open the file in your browser, to verify the include_path your web server is using. pear list -a to see all packages installed, not only from the default channel.

What does PEAR stand for in PHP?

PEAR means “PHP Extension and Application Repository.” It is a framework and distribution system for reusable PHP components. It extends PHP and gives a higher level of programming for all web developers.


2 Answers

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

like image 129
VolkerK Avatar answered Oct 01 '22 04:10

VolkerK


Another way is edit your windows system environment and add PHP_PEAR_SYSCONF_DIR variable pointing to php's dir.

like image 26
user421812 Avatar answered Oct 01 '22 03:10

user421812