dongmu5815 2018-06-28 18:52
浏览 59

Composer的Autoloader与其他人发生冲突

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!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用