Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't include pear package that definitely exists (and is installed)

Tags:

php

pear

I installed the Mail_Mime package.

include('Mail.php');
include('Mail/mime.php');

I get the following errors:

Warning: include(Mail.php) [function.include]: failed to open stream: No such file or directory in /var/www/vhosts/domain.co.uk/httpdocs/mail_mime/index.php  on line 2

Warning: include() [function.include]: Failed opening 'Mail.php' for inclusion (include_path='.:/usr/lib/php/PEAR:/usr/lib/php/modules') in /var/www/vhosts/domain.co.uk/httpdocs/mail_mime/index.php on line 2

Warning: include(Mail/mime.php) [function.include]: failed to open stream: No such file or directory in /var/www/vhosts/domain.co.uk/httpdocs/mail_mime/index.php on line 3

Warning: include() [function.include]: Failed opening 'Mail/mime.php' for inclusion (include_path='.:/usr/lib/php/PEAR:/usr/lib/php/modules') in /var/www/vhosts/domain.co.uk/httpdocs/mail_mime/index.php on line 3

the 2 files are definitely in the folders:

/usr/lib/php/PEAR/Mail.php
/usr/lib/php/PEAR/Mail/mime.php

pear list tells me that the packages required are installed and there are no missing dependencies

like image 834
mononym Avatar asked May 21 '10 13:05

mononym


2 Answers

Is it in your include path?

var_dump(get_include_path());

If it's not, try adding this before hand to add it to the include path:

at run time:

$path = get_include_path() . PATH_SEPARATOR . '/usr/lib/php/PEAR';
set_include_path($path);

Or in php.ini

include_path=".:--Whatever's here already--:/usr/lib/php/PEAR"

On a side note, if you care about it being included, why not use require_once? It'll prevent it from being included multiple times (the _once part) and causing a fatal error. It'll also prevent the execution of the rest of the code if it can't be found...

like image 181
ircmaxell Avatar answered Nov 12 '22 07:11

ircmaxell


For Plesk users using virtual hosts: don't forget to include the Directory directive in the vhost.conf in the /var/www/vhosts/yourdomain/subdomains/yoursubdomain/conf/vhost.conf when you set open_basedir to allow including the PEAR libraries

<Directory  /var/www/vhosts/yourdomain/subdomains/yoursubdomain/httpdocs>
        <IfModule mod_php4.c>
                php_admin_flag engine on
                php_admin_flag safe_mode off
                php_admin_value open_basedir "/var/www/vhosts/yourdomain/subdomains/yoursubdomain/httpdocs:/tmp:/usr/share/php"
        </IfModule>
        <IfModule mod_php5.c>
                php_admin_flag engine on
                php_admin_flag safe_mode off
                php_admin_value open_basedir "var/www/vhosts/yourdomain/subdomains/yoursubdomain/httpdocs:/tmp:/usr/share/php"
        </IfModule>
        Options -Includes -ExecCGI
</Directory>
like image 34
jumanne Avatar answered Nov 12 '22 05:11

jumanne