Skip to content

[Question] Global middleware for Queue Jobs #46163

Answered by rojtjo
ankurk91 asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not sure if this is documented anywhere, but you can use the Bus::pipeThrough() method for this:

use Illuminate\Support\Facades\Bus;

Bus::pipeThrough([
    SomeMiddleware::class,
    new SomeOtherMiddlware(),
    fn ($job, $next) => $next($job),
]);

See:
https://github.com/laravel/framework/blob/10.x/src/Illuminate/Support/Facades/Bus.php#L21
https://github.com/laravel/framework/blob/10.x/src/Illuminate/Bus/Dispatcher.php#L270-L281

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ankurk91
Comment options

@ankurk91
Comment options

Answer selected by ankurk91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants