softonic/laravel-psr15-bridge
Laravel PSR-15 Middleware Bridge
This package provides a Laravel middleware bridge for PSR-15 inspired in jshannon63/laravel-psr15-middleware.
Requirements
- PHP >= 8.5
- Laravel 12.x
Installation
To install, use composer:
composer require softonic/laravel-psr15-bridge
You are ready to use it!
Usage
The bridge adapter receive a PSR-15 middleware via injection, so the bridge is transparent for Laravel and you can use it as any other middleware.
Example based on OpenApi Validation Middleware:
Wrapping OpenApi Validation Middleware within the bridge.
// app/Providers/AppServiceProvider.php
use Softonic\Laravel\Middleware\Psr15Bridge\Psr15MiddlewareAdapter;
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->bind(OpenApiValidation::class, function () {
// Setup your PSR-15 middleware here
$validator = new \HKarlstrom\Middleware\OpenApiValidation('schema.json');
// Return it wrapped in the adapter to make Laravel accept it
return Psr15MiddlewareAdapter::adapt($validator);
});
}
Now you can use it anywhere or for example generate an alias.
// app/Http/Kernel.php
protected $routeMiddleware = [
...
'openapi-validation' => OpenApiValidation::class,
];
Check laravel middleware for more information.
How it works
In the next diagram you can see the request and response flow.

As you can see, when you execute Psr15MiddlewareAdapter::adapt($validator);, you are adding an envelop to the PSR-15
middleware that converts the request and response transparently for the middleware format Laravel expects.
Testing
softonic/laravel-psr15-bridge has a PHPUnit test suite and a coding style compliance test suite using PHP CS Fixer.
To run the tests, run the following command from the project folder.
$ docker compose run --rm test
To run PHPUnit only:
$ docker compose run --rm phpunit
To check code style:
$ docker compose run --rm php composer run phpcs
To fix code style issues:
$ docker compose run --rm fixcs
License
The Apache 2.0 license. Please see LICENSE for more information.
Related Packages
PSR-based Inertia helpers and middleware integration for PHP applications
Larafony is a modern PHP 8.5 framework combining the elegance of Laravel, the st...
Configurable localization middleware for your Laravel >=5.1 application
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 5.0.0 | >=8.5 | ^12.0 | Apache-2.0 | |
| 4.1.1 | >=8.1 | ^9.0 | | Apache-2.0 | |
| 4.1.0 | >=8.1 | ^9.0 | | Apache-2.0 | |
| 4.0.0 | >=8.1 | ^9.0 | | Apache-2.0 | |
| 3.0.0 | >=7.3 | ^8.0 | | Apache-2.0 | |
| 2.0.0 | >=7.3 | ^7.0 | | Apache-2.0 | |
| 1.4.0 | >=7.1 | ^5.6 | | Apache-2.0 | |
| 1.3.0 | >=7.1 | ^5.6 | | Apache-2.0 | |
| 1.2.0 | >=7.1 | ^5.6 | | Apache-2.0 | |
| 1.1.0 | >=7.1 | ^5.6 | | Apache-2.0 | |
| 1.0.0 | >=7.1 | ^5.6 | Apache-2.0 |