Jump to content

How can I change the include_path in order to access PEAR packages?


msns4345

Recommended Posts

Hi everyone!

 

I need to use a couple of PEAR packages for my website on heliohost, but I just can't set the include_path for my code to see these packages.

 

The PEAR packages are being installed under /home1/my_domain/php/

 

My code is in this folder: /home1/my_domain/public_html/

 

If, for example, I need to use the package Net_UserAgent_Detect

 

I have this line in my code:

require_once( "Net/UserAgent/Detect.php" );

 

and I get this error:

Fatal error: require_once() [function.require]: Failed opening required 'php/Net/UserAgent/Detect.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home1/missions/public_html/browser_sniffer.php on line 13

 

If I change the code to:

require_once( "../php/Net/UserAgent/Detect.php" );

 

then everything works fine.

 

The problem is that I need to use a lot of PEAR packages and some have tons of files I would need to modify the 'require_once' lines for.

 

I think I need to add "../php/" to my include_path in PHP but I haven't been able to do that.

 

I tried this:

ini_set("include_path", '../php:' . ini_get("include_path") );

 

but no luck. It seems like heliohost does not let me edit php.ini.

 

Can someone please tell me how I can add '../php/' to my include_path ?

 

I would be very grateful!

 

Thanks in advance.

Link to comment
Share on other sites

 

Thank you, Geoff. It works!

I see I wasn't setting the include_path correctly.

 

I notice though that the new include_path doesn't stay saved.

 

Do I have to have

 

$path = '/home1/missions/php';

set_include_path(get_include_path() . PATH_SEPARATOR . $path);

 

in all of my scripts that use the PEAR packages?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...