Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help to install PEAR package on web hosting

Status
Not open for further replies.

mpartarrieu

Programmer
Nov 21, 2006
34
ES
Hi all...

I'm developing a newsletter and found that PEAR has two excellent packages (mail and mail_queue) that do this for me using a cronjob. However I'm using a web hosting service and talked to the company that provides me this service and they confirmed me that PEAR is not installed, but they also said that I'm allowed to install any library I might need.

My question is weather it's possible to manually install PEAR and the two packages I need and, if so, how should I install them and which directory should I use (or create).

Thanks in advance for your help.

 
PEAR libraries, unlike PECL extensions, consist entirely of PHP code. You can download the file (usually a tarball or a zip file) to a directory, extract the files and use the library in situ.

You may have to tweak a few paths in some code, and you'll need to read the documentation to see what to include(), but it shouldn't be hard.


Want the best answers? Ask the best questions! TANSTAAFL!
 
to facilitate you could use go-pear from go-pear.org
 
Thanks for your advice. I finally managed to install PEAR and the packages I needed (mail and mail_queue), but now I'm getting the following error:

Code:
Fatal error: main() [function.require]: Failed opening required 'Mail/Queue.php' (include_path='/pear/PEAR/:.:/usr/local/lib/php') in /usr/home/oxersport/[URL unfurl="true"]www/site/admin/config.php[/URL] on line 2

Any ideas of what this might be?? Thaks again in advance!!!
 
you need to change your php.ini include_path to point at your new installation of the pear base class. you could use absolute paths in your include statements for pear but that's a real pain.
 
I understand what you mean, but remember that I'm using a hosting service, so I don't have access to my php.ini file. If you know a way to change it, please let me know. Thanks.

 
normally you can just create a php.ini file with the include path in it (you need just have this directive, nothing else unles you want), upload the php.ini to the folder in which your script runs and the local directive should override.
 
Hi jpadie,

Thanks again for your help. I'm knew at this PEAR thing, so excuse me if I look too stupid. I tried to follow your instructions and create a php.ini file with the following code:

Code:
ini_set('include_path', '/pear/' . PATH_SEPARATOR
        . ini_get('include_path'));

Then I uploaded it on the same folder where my scripts run and checked weather the script was working, but I still get a fatal error, very much the same I got before:

Code:
Fatal error: main() [function.require]: Failed opening required 'Mail/Queue.php' (include_path='.:/usr/local/lib/php') in /usr/home/oxersport/[URL unfurl="true"]www/site/admin/config.php[/URL] on line 2

Any additional ideas?? Thanks.
 
I still think you'll be better off just expanding the files into your web directory then referencing the files directly in your includes().


Want the best answers? Ask the best questions! TANSTAAFL!
 
your php.ini file would just include
Code:
include_path = '.:/pear'
; any other directives you want to include
assuming that the pear installation was in your root. if you want to get the existing root and include that too, i recommend that you do so manually although you could dynamically write a php.ini file which would take effect from the next time the script was run.

remember that *nix paths are case sensitive so pear is different to PEAR

if you want to fix it inside your application rather than by an ini file then you can do this:
Code:
set_include_path(get_include_path() . PATH_SEPARATOR.'/pear');

the code you posted would also work but from ver 4.3.0 the shorter forms have been available.

the reason why your code did not work is (most probably) that the php.ini you put in your website was parsed and found not to include any recognised php directives and thus ignored. thus the path was not set. It is also possible that this method of setting php directives is not supported by your host although this would be unusual (in my limited experience of hosts).
 
Thanks guys, I finally made it work following jpadie instructions. Once again, thanks!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top