PEAR directory problem on Windows

前端 未结 6 625
粉色の甜心
粉色の甜心 2021-02-02 03:24

I\'ve downloaded the ZIP archive of PHP and extracted it under my profile. I then needed some PEAR packages. go-pear.bat apparently installed PEAR just fine, I just

6条回答
  •  伪装坚强ぢ
    2021-02-02 04:03

    A slightly better option than michael h's answer might be:

    1. Open $prefix\pear\PEAR\Config.php where $prefix is the value used in the PEAR installer. (On my Windows system, $prefix was C:\php\5.4.0)

    2. Find the section below:

      if (getenv('PHP_PEAR_SYSCONF_DIR')) {
          define('PEAR_CONFIG_SYSCONFDIR', getenv('PHP_PEAR_SYSCONF_DIR'));
      } elseif (getenv('SystemRoot')) {
          define('PEAR_CONFIG_SYSCONFDIR', getenv('SystemRoot'));
      } else {
          define('PEAR_CONFIG_SYSCONFDIR', PHP_SYSCONFDIR);
      }
      
    3. And make the following changes:

      if (getenv('PHP_PEAR_SYSCONF_DIR')) {
          define('PEAR_CONFIG_SYSCONFDIR', getenv('PHP_PEAR_SYSCONF_DIR'));
      //} elseif (getenv('SystemRoot')) {
          //define('PEAR_CONFIG_SYSCONFDIR', getenv('SystemRoot'));
      } else {
          //define('PEAR_CONFIG_SYSCONFDIR', PHP_SYSCONFDIR);
      
          // This next line is new
          define('PEAR_CONFIG_SYSCONFDIR', $PEAR_INSTALL_DIR);
      }
      

    This solution is less hazard-prone when dealing with multiple PHP/PEAR versions/installations, especially when running more than one at the same time, as you avoid environment clobbering.

    Apparently the PEAR developers overlooked the fact that WINDOWS, Program Files and friends have been deprecated as application-data directories since Windows Vista, and are generally no longer writable by non-elevated applications. (For good security reasons.)

提交回复
热议问题