I am work on legacy app that includes dozens and dozens of different php scripts, all written before Composer was widespread in use.
I needed to use a package (for sending email) only available through Composer, so I created a composer directory and included it into one script like so:
include_once("/home/soccer/src/autoload.php"); // the old autoloader
require '/home/soccer/src/Mailgun/vendor/autoload.php';
use Mailgun\Mailgun;
Now the problem is that Composer's autoload (shown in line 2) works fine, and I can send mail, however now the important libraries from line 1 do not work:
PHP Fatal error: Class 'DB' not found in .....
There is a file at:
/home/soccer/src/DB.php
that is the most basic MySQL db loader imaginable. I tried adding a namespace to it with:
namespace Footyscores;
and then in the PHP script adding **Footyscores** to the function call, but no luck there, same error.
Here is the legacy autoloader:
include_once "/home/soccer/src/settings.php";
function __autoload($class)
{
global $srcDir;
$parts = explode('\\', $class);
$file = end($parts);
include_once $srcDir . $file . '.php';
}
How is I fix this? Thanks!