简体   繁体   中英

Override vendor autoload 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);

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM