softonic/laravel-psr15-bridge

Laravel PSR-15 middleware bridge
117,550 9
Install
composer require softonic/laravel-psr15-bridge
Latest Version:5.0.0
PHP:>=8.5
Laravel:12
License:Apache-2.0
Last Updated:Jan 12, 2026
Links: GitHub  ·  Packagist
Maintainer: Joskfg

Laravel PSR-15 Middleware Bridge

Latest Version Software License Build Status Total Downloads

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.

psr-15 bridge 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

maskulabs/inertia-psr

PSR-based Inertia helpers and middleware integration for PHP applications

551 4
larafony/core

Larafony is a modern PHP 8.5 framework combining the elegance of Laravel, the st...

65 89
spatie/laravel-authorize

A middleware to check authorization

27,045 201
benconstable/laravel-localize-middleware

Configurable localization middleware for your Laravel >=5.1 application

31,409 91

Version History

Version Released PHP Laravel License
5.0.0 >=8.5 ^12.0 Apache-2.0
4.1.1 >=8.1 ^9.0 || ^10.0 || ^11.0 Apache-2.0
4.1.0 >=8.1 ^9.0 || ^10.0 || ^11.0 Apache-2.0
4.0.0 >=8.1 ^9.0 || ^10.0 Apache-2.0
3.0.0 >=7.3 ^8.0 || ^9.0 Apache-2.0