1

I've been trying to use a few PEAR packages for a few hours now to no avail. PEAR itself is functioning, and I believe I set all of the configuration variables correctly, but when I try to run any of my packages from the command line, I get PHP errors telling me the required file wasn't found. For example, with phpdoc:

$ phpdoc
PHP Warning:  require(PhpDocumentor/phpDocumentor/phpdoc.inc): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/pear/bin/phpdoc on line 40

Warning: require(PhpDocumentor/phpDocumentor/phpdoc.inc): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/pear/bin/phpdoc on line 40
PHP Fatal error:  require(): Failed opening required 'PhpDocumentor/phpDocumentor/phpdoc.inc' (include_path='.:/Applications/MAMP/bin/php5.2/lib/php') in /Applications/MAMP/htdocs/pear/bin/phpdoc on line 40

Fatal error: require(): Failed opening required 'PhpDocumentor/phpDocumentor/phpdoc.inc' (include_path='.:/Applications/MAMP/bin/php5.2/lib/php') in /Applications/MAMP/htdocs/pear/bin/phpdoc on line 40

I tried manually editing the files, inserting the absolute path to the files, but when I correct one require error a new one just comes up.

This is my pear.conf:

#PEAR_Config 0.9
a:15:{s:10:"__channels";a:2:{s:12:"pecl.php.net";a:0:{}s:5:"__uri";a:0:{}}s:15:"preferred_state";s:6:"stable";s:8:"temp_dir";s:35:"/Applications/MAMP/htdocs/pear/temp";s:7:"bin_dir";s:34:"/Applications/MAMP/htdocs/pear/bin";s:7:"php_dir";s:35:"/Applications/MAMP/htdocs/pear/PEAR";s:7:"doc_dir";s:40:"/Applications/MAMP/htdocs/pear/PEAR/docs";s:8:"data_dir";s:40:"/Applications/MAMP/htdocs/pear/PEAR/data";s:8:"test_dir";s:41:"/Applications/MAMP/htdocs/pear/PEAR/tests";s:9:"cache_dir";s:41:"/Applications/MAMP/htdocs/pear/PEAR/cache";s:9:"cache_ttl";i:300;s:12:"download_dir";s:44:"/Applications/MAMP/htdocs/pear/temp/download";s:10:"http_proxy";s:0:"";s:7:"ext_dir";s:74:"/Applications/MAMP/bin/php5.2/lib/php/extensions/no-debug-non-zts-20050922";s:7:"php_bin";s:37:"/Applications/MAMP/bin/php5.2/bin/php";s:10:"sig_keydir";s:39:"/Applications/MAMP/conf/php5.2/pearkeys";}

PEAR Config

I'm using MAMP PRO v1.9.5 on Mac OS 10.7.5 with PHP v5.2.17. Also, I installed the packages with the PEAR web interface package manager. If any further information is required, please let me know and I'll post it.

HellaMad
  • 5,294
  • 6
  • 31
  • 53
  • what is the result of `php -r'var_dump(ini_get("include_path"));'` ? – hek2mgl Mar 22 '13 at 22:56
  • @hek2mgl That gives a parse error. `Parse error: parse error in Command line code on line 1` – HellaMad Mar 22 '13 at 22:58
  • Uups I missed the `;` – hek2mgl Mar 22 '13 at 22:58
  • @hek2mgl Result: `string(2) ".:"` – HellaMad Mar 22 '13 at 22:59
  • Ok than this is the problem. You'll have to add your pear class directory to the `include_path` php.ini setting. This can be done by editing the php.ini (for cli). – hek2mgl Mar 22 '13 at 23:01
  • Do you know where a) the php.ini is located and b) pear install class files? (I have no mac) – hek2mgl Mar 22 '13 at 23:04
  • @hek2mgl I'm looking for it, one moment, thanks. – HellaMad Mar 22 '13 at 23:05
  • @hek2mgl Hmm, `php --ini` gives this: `Configuration File (php.ini) Path: /etc Loaded Configuration File: (none) Scan for additional .ini files in: (none) Additional .ini files parsed: (none)` But `vi /etc/php.ini` shows a blank file. – HellaMad Mar 22 '13 at 23:06
  • Seems to be an installation problem. I wish that I could help further but I have Linux.. You'll have to make sure that a) the php.ini is processed b) `include_path='.:PEAR_CLASSES_ROOT'`. Note that php regulary processes a php.ini that is located beside the php executable in the same directory – hek2mgl Mar 22 '13 at 23:10
  • @hek2mgl I found my `php.ini` for MAMP (which is what I used to install PHP originally) and the include path listed there is `include_path = ".:/Applications/MAMP/bin/php5.2/lib/php"` – HellaMad Mar 22 '13 at 23:21
  • Do you know `dtruss`? It's a console program that lists system calls. The output of `dtruss php --ini | grep ini` would be interesting. – hek2mgl Mar 22 '13 at 23:27
  • @hek2mgl I ran `sudo cp /private/etc/php.ini.default /private/etc/php.ini`, then edited the new `php.ini` so that `include_path = ".:/Applications/MAMP/htdocs/pear/PEAR/"` (which is where the directories for my packages are), and now `var_dump(ini_get("include_path"))` gives `string(38) ".:/Applications/MAMP/htdocs/pear/PEAR/"` but I'm still getting the errors (I restarted PHP as well). – HellaMad Mar 22 '13 at 23:44
  • Use `include_path=".:/Applications/MAMP/htdocs/pear"` – hek2mgl Mar 22 '13 at 23:45
  • @hek2mgl Nope, that doesn't work either. I actually have 3 pear directories, one inside of another. I created `pear` (lowercase) myself when installing it. – HellaMad Mar 22 '13 at 23:48
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/26752/discussion-between-hek2mgl-and-dc) – hek2mgl Mar 22 '13 at 23:49

1 Answers1

2

Make sure that the include path contains the folder where PEAR installs php class files. Check your include_path ini setting. It should look like:

include_path=".:PEAR_CLASSES_PATH"

where PEAR_CLASSES_PATH is the pear class path

hek2mgl
  • 152,036
  • 28
  • 249
  • 266