0

I am a reseller on cPanel with Apache and PHP 5.5, and my server owner has just installed the latest PHPMailer on the shared folder, so it can be accessed from:

require "PHPMailerAutoload.php"; 

but, all of my current sites have PHPmailer in my class folder, with an extended class to customise the mailer details to each site.

So, my PHP class has:

require_once "class.phpmailer.php";

class ChoiceMailerSMTP extends PHPMailer {
            /**
            * Mailer 
            *
            **/

My issue is that since my server guy has put on the shared folder, the new PHPMailer, that now all of my require calls are searching the Shared folder BEFORE searching the local folder, and therefore loading the wrong phpmailer.class.php.

This is really frustrating, although in this instance it's (only) a hassle - if he puts other files in the shared folder for himself or for others, how am I meant to ensure that my PHP includes and requires run the local rather than shared files?

Is there a line in php.ini I can use? Or perhaps a cPanel setting? require "./file" doesn't work.

EDIT:

I've been doing some research on my system and found that set include path is already set to:

include_path = ".:/usr/lib/php:/usr/local/lib/php"

So any help why the local directory is only searched after the include path directories?

2 Answers 2

1

The include order of relative paths depends on the set include path, see set_include_path. You can either modify that include path to prioritise your local folder, or you can use an explicit absolute path for includes to begin with:

require_once __DIR__ . '/class.phpmailer.php';
Sign up to request clarification or add additional context in comments.

2 Comments

I just this second discovered DIR for this use, I am looking at using the set_include_path, cheers
Seems the include path is already set as expected so I'm not sure what's causing it to not search the current directory first :-/ . However using the DIR Magic Constant does work, but would still require going in and editing every include call :-/
0

What's wrong with the shared version? Is it older than yours?

You can adjust the order that directories are searched by changing the include_path directive in php.ini.

You should be loading the autoloader anyway, as it always looks for class files relative to itself, so, similar to @deceze's suggestion, you should do:

require_once __DIR__ . '/PHPMailerAutoload.php';

1 Comment

the point is that the shared file is taking precedence, when the site is made with the local file as the intended target. the fact it's PHPMailer and Autoloaders is not the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.