覆盖供应商自动加载作曲家 [英] Override vendor autoload composer

查看:83
本文介绍了覆盖供应商自动加载作曲家的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以在调用供应商自动加载之前运行您创建的自动加载文件?我们似乎遇到了SimpleSAML的自动加载替换我们创建的自动加载文件之一的问题。我是Composer的新手,似乎无法在线找到任何解决方案。

Is there a way to have an autoload file you created run before the vendor autoload is called? We seem to be running into an issue with SimpleSAML's autoload overriding one of the autoload files we created. I am new to Composer, and couldn't seem to find any solutions online.

我尝试将我们的自动加载文件也包含在需要它的文件中,但仍然可以不行。

I tried including our autoload file in the file that needs it as well and that still did not work.

一种解决方法是仅显式地包含文件,但是能够使用自动加载器将是首选。

A workaround is to just include the files explicitly, but being able to use the autoloader would be preferred.

推荐答案

是的,您可以注册自动装带器并将其装在队列中,例如:

Yes, you can register an autoloader and prepend it to the queue, for example:

spl_autoload_register(function($class) {
    // ...
}, true, true);

最后一个参数(true)会将此自动加载器添加到队列中,因此将其称为首先,要做到这一点,您必须在脚本的早期就注册自动加载器,也许是在包括供应商自动加载器之后立即注册。 在此处了解更多信息

The last parameter (true) will prepend this autoloader into the queue, so, it'll be called at first and to do that, you've to register your autoloader at the very early of your script, maybe just right after you include the vendor autoloader. Read more here.

这篇关于覆盖供应商自动加载作曲家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆