Download the PHP package membrane/laravel without Composer
On this page you can find all versions of the php package membrane/laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel
Membrane-Laravel
Integrates Membrane-core with Laravel.
About
Middleware that validates the raw user input from incoming HTTP requests against your OpenAPI spec.
Adds a Membrane\Result\Result
onto your Illuminate\Contracts\Container\Container
.
The Result object contains the cleaned up data and additional details in the case of invalid requests.
Setup
Installation
Require the membrane/laravel
package in your composer.json and update your dependencies:
Configuration
The defaults are set in config/membrane.php
.
To publish a copy to your own config, use the following:
API Spec File
This is the absolute filepath of your OpenAPI.
By default, it looks for <your-project-directory>/api/openapi.yaml
.
Validation Error Response Code
Set 'validation_error_response_code'
to the integer value of the default http status code for invalid results.
Validation Error Response Type
Set 'validation_error_response_type'
to the string value of the default response type for API problems.
API Problem Response Types
Within the 'api_problem_response_types'
array:
Set integer http status code => string response type pairs.
These are more specific and will override the default value set by 'validation_error_response_type'
Usage
Requests
The \Membrane\Laravel\Middleware\RequestValidation
middleware will validate or invalidate incoming requests and let
you decide
how to react.
You can follow it with your own custom middleware or with one of the following built-in options to produce an error
response:
Responses
Any response middleware MUST follow the RequestValidation
middleware as it requires the result
object being added to
your container.
These middlewares will check whether the request has passed or failed validation.
Invalid requests will return an appropriate response detailing the reasons the request was invalid.
Your response can be in one of the following formats.
Flat Json
\Membrane\Laravel\Middleware\ResponseJsonFlat
Nested Json
\Membrane\Laravel\Middleware\ResponseJsonNested
Global Usage
To use any of the above middlewares on all routes, go into your app/Http/Kernel.php
and add them to your middleware
array.
For example:
All versions of laravel with dependencies
crell/api-problem Version ^3.6.1
illuminate/console Version ^9.0 || ^10.0
illuminate/http Version ^9.0 || ^10.0
illuminate/support Version ^9.0 || ^10.0
nyholm/psr7 Version ^1.8
membrane/membrane Version ^0.8
membrane/openapi-router Version ^0.4.0
symfony/psr-http-message-bridge Version ^2.1