Override vendor autoload composer

2019-08-20 16:32发布

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条回答
Evening l夕情丶
2楼-- · 2019-08-20 17:30

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.

查看更多
登录 后发表回答