Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Dispatcher Laravel Package

hyperf/dispatcher

Hyperf Dispatcher is a PSR-14 compatible event dispatcher for the Hyperf framework, offering coroutine-friendly event handling, flexible listener registration, and seamless integration with Hyperf's dependency injection container for scalable PHP services.

View on GitHub
Deep Wiki
Context7

🚀 A coroutine framework that focuses on hyperspeed and flexibility. Building microservice or middleware with ease.

Frequently asked questions about Dispatcher
What is hyperf/dispatcher used for?
hyperf/dispatcher provides the middleware dispatcher that Hyperf's HTTP server uses to run an ordered pipeline around a core request handler. It composes global and route middleware consistently and passes PSR-7/PSR-15-style requests through layered handlers. Use it when you need Hyperf's native dispatch behavior rather than a generic standalone router.
Can I install hyperf/dispatcher in a Laravel application?
Not as a drop-in. Composer may resolve it alongside Laravel, but the package depends on Hyperf's container, config loader, and coroutine runtime. Laravel already ships its own middleware pipeline, so pulling this in adds version coupling without architectural gain. If you need Hyperf's coroutine stack, run it as a separate service behind your Laravel app.
Is hyperf/dispatcher a PSR-14 event dispatcher?
No. hyperf/dispatcher is a middleware pipeline dispatcher, not an event dispatcher. PSR-14 event handling in Hyperf is provided by hyperf/event, and some package blurbs conflate the two. Check the actual class you need, such as the middleware dispatcher versus an event dispatcher, before adding the dependency.
Does hyperf/dispatcher require Swoole or Swow?
It is built for Hyperf's PHP-CLI coroutine runtime, which runs on Swoole or Swow. The dispatcher assumes that request lifecycle and is not designed for the classic PHP-FPM model used by most Laravel deployments. Plan separate runtime images and CI pipelines if you adopt it.
How do I install hyperf/dispatcher and which PHP version does it need?
Install it with composer require hyperf/dispatcher. In most Hyperf applications it arrives transitively through hyperf/http-server or the hyperf/hyperf metapackage, so check composer show before pinning it explicitly. Hyperf 3.2 requires PHP 8.2 or newer, so rebuild your base image, CI matrix, and local dev environment before upgrading.
How do I register global and route middleware with hyperf/dispatcher?
Global middleware is registered in Hyperf's config/autoload/middlewares.php, while route middleware is attached through route definitions or annotations. The dispatcher then runs them in order, delegating to the next handler until the core handler is reached. Keep ordering explicit because the sequence determines whether auth, logging, or validation runs first.
Can I write custom middleware or a custom dispatcher implementation?
Yes. Custom middleware implements Hyperf's middleware interface with a process method that receives the request and the next handler, then calls the next handler to continue the pipeline. The package also supports custom dispatcher implementations, and it centralizes dispatch exception handling so failures are managed consistently. Test custom middleware in isolation before wiring it into global stacks.
How should I test middleware that uses hyperf/dispatcher?
Hyperf 3.2 aligns with PHPUnit 11, so use it for unit tests that call the dispatcher with a stub core handler and assert the order of middleware execution. Coroutine-aware tests should run inside the Hyperf testing harness rather than a plain PHPUnit bootstrap. Run PHPStan at a meaningful level to catch removed APIs and renamed methods before they reach production.
What are the alternatives to hyperf/dispatcher?
For Laravel applications, the native Illuminate Pipeline and Laravel's own middleware stack cover most of the same ground. PSR-15 dispatchers such as laminas-stratigility or middlewares/utils are options for non-Hyperf PSR-15 projects, and Symfony's HttpKernel listeners serve a similar role. Within Hyperf, the framework's pipeline utilities and HTTP server components are the closest equivalents.
Is hyperf/dispatcher production-ready, and what breaks when upgrading to Hyperf 3.2?
It is a core Hyperf component used by the framework's HTTP server, so it is production-grade within that ecosystem. The 3.2 upgrade is the bigger risk: published logger and cache configs move to new schemas, async-queue methods are renamed, Carbon 3 changes day-diff and timestamp behavior silently, and several APIs are removed. Audit every environment overlay, republish configs, and treat the PHP 8.2 floor as a deploy blocker rather than a routine bump.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
vento/laravel-airbrake
wfeller/laravel-batch
maco-studios/mage-os-installer
busarm/armie
siberfx/laravel-logger
kfteam1991/dcat-admin
dashed/dashed-laposta
dashed/dashed-ecommerce-montaportal
dashed/dashed-ecommerce-etsy
neohq/string-blade-compiler
log1x/acf-composer
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager