- What is hyperf/pipeline used for?
- hyperf/pipeline is a lightweight pipeline component for Hyperf applications. It passes data through a series of stages or middleware, letting you build clean, configurable request-processing workflows. Stages can be written as closures or classes, so both quick inline steps and reusable components are supported.
- How do I install hyperf/pipeline with Composer?
- Install it with composer require hyperf/pipeline from your Hyperf project root. Check the package composer.json after installation for the exact PHP and Hyperf version constraints it requires. If your application uses Hyperf configuration or dependency injection for pipeline stages, register or bind those classes according to your project structure.
- Is hyperf/pipeline compatible with Laravel?
- No, hyperf/pipeline is built for the Hyperf framework, not Laravel. Laravel ships its own pipeline implementation through illuminate/pipeline, which is the appropriate choice for Laravel applications. The concepts are similar, but you should not expect Laravel service providers, facades, or Laravel container integration from this package.
- Which Laravel versions support hyperf/pipeline?
- None. hyperf/pipeline is a Hyperf package, so Laravel version constraints do not apply to it. If you are working in a Laravel application, use Illuminate\Pipeline or a framework-agnostic package such as league/pipeline instead. For Hyperf projects, check the package composer.json for supported Hyperf and PHP versions.
- How do I define a pipeline stage with a closure or class?
- The package supports both closures and classes as pipeline stages, matching the lightweight pipeline concept described in its overview. Closures are useful for short transformations, while class stages are better for reusable or dependency-injected logic. Verify the exact stage interface and method signature in the package source or README before implementing production stages.
- Can hyperf/pipeline be used for middleware-style request processing?
- Yes, the package is intended for middleware-style workflows where data passes through ordered stages. You can use it to build custom request-processing chains that inspect, transform, or validate a payload before returning a result. It is not a replacement for Hyperf's HTTP middleware system, but it works well for application-level pipelines that need explicit ordering and configuration.
- How do I test a pipeline built with hyperf/pipeline?
- Unit test individual stages in isolation by passing controlled payloads and asserting the returned values. Then add integration tests that run the full pipeline with a representative payload and assert the final output and stage order. Closures are especially easy to test inline, while class stages can be instantiated directly with test doubles for their dependencies.
- What are the production concerns when using hyperf/pipeline?
- Keep each stage small and focused so failures are easy to trace and reorder. In long-running Hyperf workers, avoid mutable state in reusable stage objects because worker processes handle many requests over their lifetime. Also handle exceptions deliberately and monitor pipeline depth, since long chains can obscure where a payload was changed or rejected.
- What alternatives exist to hyperf/pipeline?
- For Laravel applications, illuminate/pipeline is the native option and integrates with the Laravel container. Framework-agnostic alternatives include league/pipeline, and you can always write a small custom middleware chain without a package. Hyperf's own HTTP middleware is a separate concept but may be a better fit for transport-level request handling.
- How is hyperf/pipeline maintained and which Hyperf versions does it support?
- The package is published under the hyperf vendor name, which is the official Hyperf organization. Check Packagist and the package composer.json for the latest release, supported PHP versions, and Hyperf version constraints. The context provided here does not list specific release or version details, so verify those before adopting it in a production project.