Download the PHP package asb/middleware-pipe without Composer
On this page you can find all versions of the php package asb/middleware-pipe. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download asb/middleware-pipe
More information about asb/middleware-pipe
Files in asb/middleware-pipe
Package middleware-pipe
Short Description This is the pattern that Laravel uses for its HTTP Middleware as well as its internal Pipeline; each Middleware can execute its own logic before and after executing the next step ($next).
License MIT
Informations about the package middleware-pipe
Middleware Pipeline
A lightweight and framework-independent middleware pipeline for PHP.
This package allows you to execute one or more middleware classes before and after calling a class method. It follows the same pipeline pattern used by Laravel's middleware system but can be used in any PHP project.
Features
- 🚀 Simple and lightweight
- 📦 No framework dependency
- 🔗 Supports multiple middleware
- 🔄 Execute code before and after the target method
- 🧩 Supports both object and static method calls
- ⚡ PHP 8.0+
Requirements
- PHP 8.0 or higher
Installation
Install via Composer:
Middleware Structure
Every middleware must implement a handle() method.
Example:
The $next callback continues the execution of the pipeline.
Using the Trait
Add the trait to your class.
Object Example
Execution order:
Static Example
How It Works
The package builds a middleware pipeline using nested closures.
Calling
starts the execution.
Execution flow:
Each middleware can:
- Execute code before the target method.
- Execute code after the target method.
- Modify the returned value.
- Stop the pipeline without calling
$next.
Example Middleware
Multiple Middlewares
Execution order:
License
This project is open-sourced software licensed under the MIT License.
Author
Developed by Abouzar Rostami.