PEAR directory problem on Windows

前端 未结 6 626
粉色の甜心
粉色の甜心 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 03:51

    Look at the config-... parameters of the PEAR command:

    config-create          Create a Default configuration file
    config-get             Show One Setting
    config-help            Show Information About Setting
    config-set             Change Setting
    config-show            Show All Settings
    

    I presume C:\php5 is the builtin default directory when you don't set another one.

    0 讨论(0)
  • 2021-02-02 04:01

    you can specify the config file via

    pear -c /path/to/config/file $command
    
    0 讨论(0)
  • 2021-02-02 04:02

    I've had the same problem. My config file was missing from the C:\Windows directory - there is definitely something wrong with the go-pear installer - I specified a different INI file location, yet my wish has not come true.

    I copied pear.ini to C:\windows and everything started to work.

    0 讨论(0)
  • 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.)

    0 讨论(0)
  • 2021-02-02 04:06

    The problem is that PEAR looks for its ini file in the Windows directory, and because it doesn't find it there, it resorts to guessing the location. Even worse, you can't change any configuration settings with pear config-set because PEAR doesn't have a pear.ini to write to. At the same time, PEAR ignores an existing pear.ini file in its own directory. It's a mess. See this bug report.

    If there is just one global PEAR install, PEAR can be told where to look for an ini file by creating an environment variable, PHP_PEAR_SYSCONF_DIR, pointing to the right directory.

    But if there are multiple, local PEAR installs, you'll have to patch pear.bat by adding this line:

    IF "%PHP_PEAR_SYSCONF_DIR%"=="" SET "PHP_PEAR_SYSCONF_DIR=C:\path\to\pear.ini\directory"

    0 讨论(0)
  • 2021-02-02 04:07

    If your PHP installation has been done somewhere else other than the C:\ drive, then “pear install” command may throw errors.

    Example: Here in my case, the xampp has been installed into E:\ drive and the “pear install” throws error.

    Error got when I run the command. This also happen for PHPDocumentor Solution: I get into the “pear” directory and checked config values set for different pear related directories. All were set to C:\ drive by default. So, we need to change those settings to correct path. Open the command prompt in "Run as administrator" mode.

    Pear default setting Now change five path in xampp like this

    E:\xampp\php>
    E:\xampp\php>pear config-set doc_dir E:\xampp\php\pear
    

    If you are using C drive and getting the same error then also the above statement will remain same just replace the drive name E:\ to C:\ vice versa. example for C: drive

    C:\xampp\php>pear config-set doc_dir C:\xampp\php\pear
    

    Then press enter it will display a msg of config-set succeeded

    Like this you have to enter 5 commands.

    E:\xampp\php>pear config-set doc_dir E:\xampp\php\pear
    

    config-set succeeded

    E:\xampp\php>pear config-set cfg_dir E:\xampp\php\pear
    

    config-set succeeded

    E:\xampp\php>pear config-set data_dir E:\xampp\php\pear
    

    config-set succeeded

    E:\xampp\php>pear config-set test_dir E:\xampp\php\pear
    

    config-set succeeded

    E:\xampp\php>pear config-set www_dir E:\xampp\php\pear
    

    config-set succeeded

    Finally installed pear

    0 讨论(0)
提交回复
热议问题