{"id":13395590,"url":"https://github.com/Lansoweb/api-problem","last_synced_at":"2025-03-13T22:30:36.523Z","repository":{"id":62519089,"uuid":"46662418","full_name":"Lansoweb/api-problem","owner":"Lansoweb","description":"PHP middleware that returns a json formatted response in case of error","archived":false,"fork":false,"pushed_at":"2019-04-01T16:22:10.000Z","size":19,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-07-31T18:15:18.716Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lansoweb.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}},"created_at":"2015-11-22T13:44:52.000Z","updated_at":"2020-07-17T18:26:50.000Z","dependencies_parsed_at":"2022-11-02T14:46:01.218Z","dependency_job_id":null,"html_url":"https://github.com/Lansoweb/api-problem","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lansoweb%2Fapi-problem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lansoweb%2Fapi-problem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lansoweb%2Fapi-problem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lansoweb%2Fapi-problem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lansoweb","download_url":"https://codeload.github.com/Lansoweb/api-problem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221417169,"owners_count":16816822,"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":[],"created_at":"2024-07-30T18:00:25.038Z","updated_at":"2024-10-25T10:30:17.756Z","avatar_url":"https://github.com/Lansoweb.png","language":"PHP","readme":"# Api Problem Middleware for PHP\n\nThis middleware returns a formatted json in case of error. It's inspired on the [ApiProblem](https://github.com/zfcampus/zf-api-problem) library, but with fewer dependencies. \n\n## Usage\n\nJust add the middleware as the last in your application.\n\nFor example:\n```php\n$app-\u003epipe(new \\LosMiddleware\\ApiProblem\\ApiProblem());\n```\n\nIt will return:\n```\n{\n  \"type\": \"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html\",\n  \"title\": \"Method Not Allowed\",\n  \"status\": 405,\n  \"detail\": \"error\",\n  \"code\": \"14868ef1-7ef4-4feb-a7ae-9a12c9097375\"\n}\n```\n\n### Zend Expressive\n\nIf you are using [expressive-skeleton](https://github.com/zendframework/zend-expressive-skeleton), you can copy `config/los-api-problem.global.php.dist` to `config/autoload/los-api-problem.global.php`.\n\nIt uses the FinalHandler feature from Expressive. If you prefer to use other FinalHandler, you can manually add this middleware:\n\n```php\nreturn [\n    'dependencies' =\u003e [\n        'invokables' =\u003e [\n            LosMiddleware\\ApiProblem\\ApiProblem::class =\u003e LosMiddleware\\ApiProblem\\ApiProblem::class,\n        ],\n    ],\n    'middleware_pipeline' =\u003e [\n        'error' =\u003e [\n            'middleware' =\u003e [\n                LosMiddleware\\ApiProblem\\ApiProblem::class, \n            ]\n            'error' =\u003e true,\n        ],\n    ],\n];    \n``` \n\nBut 404 errors will not be handled but this, only by the FinalHandler.\n","funding_links":[],"categories":["Middleware"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLansoweb%2Fapi-problem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLansoweb%2Fapi-problem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLansoweb%2Fapi-problem/lists"}