PHP code example of softonic / laravel-psr15-bridge

1. Go to this page and download the library: Download softonic/laravel-psr15-bridge library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

softonic / laravel-psr15-bridge example snippets


// 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);
    });
}

// app/Http/Kernel.php

protected $routeMiddleware = [
    ...
    'openapi-validation' => OpenApiValidation::class,
];