softonic/laravel-psr15-bridge 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

softonic/laravel-psr15-bridge

最新稳定版本:4.1.1

Composer 安装命令:

composer require softonic/laravel-psr15-bridge

包简介

Laravel PSR-15 middleware bridge

README 文档

README

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

This package provides a Laravel middleware bridge for PSR-15 inspired in jshannon63/laravel-psr15-middleware.

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 test

License

The Apache 2.0 license. Please see LICENSE for more information.

统计信息

  • 总下载量: 101.49k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 5
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2019-01-24