Pear Packages not working - php

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";}
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.

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

Related

Require_once(Net/URL2.php): failed to open stream: no such file or directory

I installed the pear/http_request2 version 2.2.1 using Composer in my project but when I am trying to make my first request I am getting this Warning and Fatal error:
Warning: require_once(Net/URL2.php): failed to open stream: No such
file or directory in
/Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/http_request2/HTTP/Request2.php
on line 24
Fatal error: require_once(): Failed opening required 'Net/URL2.php'
(include_path='/Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/pear_exception:.:/Applications/XAMPP/xamppfiles/lib/php')
in
/Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/http_request2/HTTP/Request2.php
on line 24
I appreciate any help on how to fix it, thanks in advance.
David.
This should work:
composer require pear/http_request2:2.2.1
By default pear/net_url2 should be installed which has the required URL2.php file (./vendor/pear/net_url2/Net/URL2.php).
Then make sure you're including vendor/autoload.php file in your scripts to load automatically the include paths (see: vendor/composer/include_paths.php file).
Here is a simple PHP command to test this out:
php -r 'require_once "vendor/autoload.php"; require_once "Net/URL2.php";'
Note: The above command should run without any errors.
Related: Errors in the autoloaded HTTP/Request2 code, how to troubleshoot composer?
You need HTTP_Request2 from git master, because it has not been released/tagged yet at the time of writing.

PHPunit test not working

I'm trying to learn zend framework 2 with this phpunit added, but I cannot get it work. I've followed the steps in the official zf2 tutorial (http://framework.zend.com/manual/2.0/en/user-guide/unit-testing.html) and now I'm facing some kind of error message clueless
Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in C:\xampp\php\pear\PHPUnit\Autoload.php on line 64
Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.;\php\zend_framework\library;\php\pear\PEAR') in C:\xampp\php\pear\PHPUnit\Autoload.php on line 64
PS C:\xampp\htdocs\new103\module\Application\test>
Needed to change the php.ini include_path to list of absolute paths, phpunit can be ran now.

phpdoc on Netbeans using MAMP not working

I am trying to get phpdoc working on netbeans but I am getting the following error
PHP Warning: require(PhpDocumentor/phpDocumentor/phpdoc.inc): failed to open stream: No such file or directory in /Applications/MAMP/bin/php/php5.4.4/bin/phpdoc on line 40
PHP Fatal error: require(): Failed opening required 'PhpDocumentor/phpDocumentor/phpdoc.inc' (include_path='.:') in /Applications/MAMP/bin/php/php5.4.4/bin/phpdoc on line 40
When I run
pear config-show in the Terminal I get the following php_dir path
/Applications/MAMP/bin/php/php5.4.4/lib/php
I have checked that the php.ini file exits and it does under
/Applications/MAMP/bin/php/php5.4.4/lib/php/phpDocumentor/phpDocumentor/phpdoc.ini
Does anyone know what the problem can be or how to resolve it. I want to use the phpdoc using Netbeans and not have to revert to the Terminal every time I want to update my documentation.
You need to edit include_path in php.ini to add PEAR's php_dir value to it. Notice in the error message that your include_path is set to nothing but ".". As such, the only place PHP is looking for PhpDocumentor/phpDocumentor/phpdoc.inc is right there in your /Applications/MAMP/bin/php/php5.4.4/bin directory. Once you add /Applications/MAMP/bin/php/php5.4.4/lib/php to your include_path, then PHP will be able to find the phpdoc.inc file at runtime.

php.ini.default not finding new path to cloudfusion on Mac OS X Snow Leopard

I'm trying to follow along with a book on Amazon EC2 and it says to include a new file path in php.ini in the etc folder to the cloudfusion sdk. So I uncommented the path variable in php.ini.default and set the new path to be:
include_path = ".:/php/includes:/Users/john/cloudfusion"
but yet when I try running my php script inside a folder named amazon, it keeps giving me the error:
Warning: require_once(sdk.class.php): failed to open stream: No such file or directory in /Users/john/amazon/create_bucket.php on line 26
Fatal error: require_once(): Failed opening required 'sdk.class.php' (include_path='.:') in /Users/john/amazon/create_bucket.php on line 26
Anybody have any ideas?
PHP doesn't read php.ini.default, it just defaults to the values in it internally, to make sure your changes are read, you can copy that file to php.ini and edit your values.
Alternatively you can use http://nl3.php.net/ini_set function to modify your include path on-the-fly. You need to use ini_set before the actual require_once.

Pear installed, but php includes provides errors

I just leased a dedicated windows server with Plesk 10.4 installed. I assumed that php, etc would all be configured and that I could prot my sites over with no isses...
Turns out the default image didn't have pear installed...I believe i need pear so include statements work in php...so I used go-pear.bat to install it...
However, I'm still getting an error when including (you can follow the path to see the file exists)
Warning: include(Connections/SamConnection.php) [function.include]: failed to open stream: Operation not permitted in C:\Inetpub\vhosts\80stunes.com\httpdocs\index.php on line 3
Warning: include() [function.include]: Failed opening 'Connections/SamConnection.php' for inclusion (include_path='.;C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\PEAR;C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5;./includes;./pear') in C:\Inetpub\vhosts\80stunes.com\httpdocs\index.php on line 3
Any ideas on what I have done wrong? I can run pear commands from a command prompt when accessing my pleskphp5 directory
Sounds like you may have open_basedir enabled.

Categories