{"id":24075512,"url":"https://github.com/membrane-php/membrane-laravel","last_synced_at":"2026-03-15T02:02:00.729Z","repository":{"id":64390831,"uuid":"574444174","full_name":"membrane-php/membrane-laravel","owner":"membrane-php","description":"Laravel integration for Membrane validation library.","archived":false,"fork":false,"pushed_at":"2025-04-22T11:45:14.000Z","size":95,"stargazers_count":3,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-30T05:05:01.813Z","etag":null,"topics":["laravel","membrane","openapi","openapi-validation","openapi3"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/membrane-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-05T10:25:52.000Z","updated_at":"2025-04-22T11:45:17.000Z","dependencies_parsed_at":"2024-03-20T15:46:17.168Z","dependency_job_id":"c5b9900a-62bd-4cd7-8909-a10f904c9b3f","html_url":"https://github.com/membrane-php/membrane-laravel","commit_stats":{"total_commits":29,"total_committers":2,"mean_commits":14.5,"dds":"0.10344827586206895","last_synced_commit":"fc312ac30a95286afc8d820ba640ced889b4ff55"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membrane-php%2Fmembrane-laravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membrane-php%2Fmembrane-laravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membrane-php%2Fmembrane-laravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membrane-php%2Fmembrane-laravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/membrane-php","download_url":"https://codeload.github.com/membrane-php/membrane-laravel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251644841,"owners_count":21620632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","membrane","openapi","openapi-validation","openapi3"],"created_at":"2025-01-09T19:06:23.537Z","updated_at":"2026-03-15T02:02:00.723Z","avatar_url":"https://github.com/membrane-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Membrane-Laravel\n\nIntegrates [Membrane-core](https://github.com/membrane-php/membrane-core) with [Laravel](https://laravel.com/).\n\n## About\n\nMiddleware that validates the raw user input from incoming HTTP requests against your OpenAPI spec.  \nAdds a `Membrane\\Result\\Result` onto your `Illuminate\\Contracts\\Container\\Container`.  \nThe Result object contains the cleaned up data and additional details in the case of invalid requests.\n\n## Setup\n\n### Installation\n\nRequire the `membrane/laravel` package in your composer.json and update your dependencies:\n\n```shell\ncomposer require membrane/laravel\n```\n\n### Configuration\n\nThe defaults are set in `config/membrane.php`.  \nTo publish a copy to your own config, use the following:\n\n```shell\nphp artisan vendor:publish --tag=\"membrane\"\n```\n\n#### API Spec File\n\nThis is the **absolute** filepath of your OpenAPI.\n\nBy default, it looks for `\u003cyour-project-directory\u003e/api/openapi.yaml`.\n\n#### Validation Error Response Code\n\nSet `'validation_error_response_code'` to the **integer** value of the default http status code for invalid results.\n\n#### Validation Error Response Type\n\nSet `'validation_error_response_type'` to the **string** value of the default response type for API problems.\n\n#### API Problem Response Types\n\nWithin the `'api_problem_response_types'` array:\nSet **integer** http status code =\u003e **string** response type pairs.  \nThese are more specific and will override the default value set by `'validation_error_response_type'`\n\n## Usage\n\n### Requests\n\nThe `\\Membrane\\Laravel\\Middleware\\RequestValidation` middleware will validate or invalidate incoming requests and let\nyou decide\nhow to react.\nYou can follow it with your own custom middleware or with one of the following built-in options to produce an error\nresponse:\n\n### Responses\n\nAny response middleware MUST follow the `RequestValidation` middleware as it requires the `result` object being added to\nyour container.  \nThese middlewares will check whether the request has passed or failed validation.  \nInvalid requests will return an appropriate response detailing the reasons the request was invalid.\n\nYour response can be in one of the following formats.\n\n#### Flat Json\n\n`\\Membrane\\Laravel\\Middleware\\ResponseJsonFlat`\n\n```json\n{\n    \"errors\":{\n        \"pet-\u003eid\":[\"must be an integer\"],\n        \"pet\":[\"name is a required field\"]\n    },\n    \"title\":\"Request payload failed validation\",\n    \"type\":\"about:blank\",\n    \"status\":400\n}\n```\n\n#### Nested Json\n\n`\\Membrane\\Laravel\\Middleware\\ResponseJsonNested`\n\n```json\n{\n    \"errors\":{\n        \"errors\":[],\n        \"fields\":{\n            \"pet\":{\n                \"errors\":[\n                    \"name is a required field\"\n                ],\n                \"fields\":{\n                    \"id\":{\n                        \"errors\":[\n                            \"must be an integer\"\n                        ],\n                        \"fields\":[]\n                    }\n                }\n            }\n        }\n    },\n    \"title\":\"Request payload failed validation\",\n    \"type\":\"about:blank\",\n    \"status\":400\n}\n```\n\n### Global Usage\n\nTo use any of the above middlewares on all routes, go into your `app/Http/Kernel.php` and add them to your `middleware`\narray.\n\nFor example:\n\n```php\nprotected $middleware = [\n  \\Membrane\\Laravel\\Middleware\\RequestValidation::class,\n  \\Membrane\\Laravel\\Middleware\\ResponseJsonFlat::class\n  // ...\n];\n```\n\nIn Laravel 11.x/12.x `app/HttpKernel.php` has been removed, global configuration goes into `bootstrap/app.php`:\n\nFor example:\n\n```php\nreturn Application::configure(basePath: dirname(__DIR__))\n    // ...\n    -\u003ewithMiddleware(function (Middleware $middleware) {\n        // ...\n        $middleware-\u003eappendToGroup('api', [\n            \\Membrane\\Laravel\\Middleware\\RequestValidation::class,\n            \\Membrane\\Laravel\\Middleware\\ResponseJsonFlat::class,\n        ]);\n    })\n    // ...\n    -\u003ecreate();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmembrane-php%2Fmembrane-laravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmembrane-php%2Fmembrane-laravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmembrane-php%2Fmembrane-laravel/lists"}