Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

booni3's avatar

Replace a core class that is not in the IOC

I want to extend/switch-out the Illuminate\Queue\SqsQueue class. The problem I have is that this queue is already being extended by another package I am using (Laravel Vapor).

If I simply extend the SQS queue implementation in the IOC, then vapor overwrites it.

One way I could do this is to:

  1. Disable the vapor service provider.
  2. Write my own that extends it.
  3. Extend the SQS queue myself, using the same method as vapor but then switch out with my Illuminate\Queue\SqsQueue class.

This feels like I am changing a lot / would need to maintain a lot when all I need to do is switch out/extend the one class.

Second to this, if we are not using vapor then I would still want the switch out to happen, so it would mean repeating the process again for each new implementation.

What I really want to do, it just tells Laravel to use my class whenever it tries to instantiate SqsQueue::class.

I know this can be hacked in composer, but what is the proper way of doing it?

0 likes
0 replies

Please or to participate in this conversation.