Override vendor autoload composer

微笑、不失礼 提交于 2019-12-25 01:34:27

问题


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.


回答1:


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

spl_autoload_register(function($class) {
    // ...
}, 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.



来源:https://stackoverflow.com/questions/50913441/override-vendor-autoload-composer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!