{"id":33120562,"url":"https://github.com/middlewares/json-exception-handler","last_synced_at":"2026-01-07T23:54:51.715Z","repository":{"id":55506908,"uuid":"151672565","full_name":"middlewares/json-exception-handler","owner":"middlewares","description":"Middleware to catch exceptions and output them as JSON","archived":false,"fork":false,"pushed_at":"2025-03-26T14:44:08.000Z","size":18,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-07-14T09:30:12.466Z","etag":null,"topics":["exception","handler","json","middleware","php","psr-15"],"latest_commit_sha":null,"homepage":"","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/middlewares.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-05T04:59:25.000Z","updated_at":"2025-03-22T19:59:31.000Z","dependencies_parsed_at":"2022-08-15T02:00:55.042Z","dependency_job_id":null,"html_url":"https://github.com/middlewares/json-exception-handler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/middlewares/json-exception-handler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Fjson-exception-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Fjson-exception-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Fjson-exception-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Fjson-exception-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/middlewares","download_url":"https://codeload.github.com/middlewares/json-exception-handler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Fjson-exception-handler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285335552,"owners_count":27154282,"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","status":"online","status_checked_at":"2025-11-19T02:00:05.673Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["exception","handler","json","middleware","php","psr-15"],"created_at":"2025-11-15T04:00:44.060Z","updated_at":"2025-11-19T22:01:46.740Z","avatar_url":"https://github.com/middlewares.png","language":"PHP","funding_links":[],"categories":["Packages"],"sub_categories":["Errors management"],"readme":"# middlewares/json-exception-handler\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE)\n![Testing][ico-ga]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nCatches exceptions that occur during request handling and output them as JSON.\n\n## Requirements\n\n* PHP \u003e= 7.2\n* A [PSR-7](https://packagist.org/providers/psr/http-message-implementation) http message implementation ([Diactoros](https://github.com/zendframework/zend-diactoros), [Guzzle](https://github.com/guzzle/psr7), [Slim](https://github.com/slimphp/Slim), etc...)\n* A [PSR-15 middleware dispatcher](https://github.com/middlewares/awesome-psr15-middlewares#dispatcher)\n\n## Installation\n\nThis package is installable and autoloadable via Composer as [middlewares/json-exception-handler](https://packagist.org/packages/middlewares/json-exception-handler).\n\n```sh\ncomposer require middlewares/json-exception-handler\n```\n\n## JsonExceptionHandler\n\nCatches exceptions thrown that occur later in request processing an creates a new response with HTTP 500 status and JSON encoded version of the exception as the body.\n\n### `contentType(string $type)`\n\nChange the Content-Type header of the response. Default is `application/json`.\n\n### `includeTrace(bool $enable)`\n\nEnable or disable the stack trace in the response. Default is `true`.\n\n### `jsonOptions(int $options)`\n\nSet options for `json_encode` of the exception. Default is `0`.\n\n---\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information about recent changes and [CONTRIBUTING](CONTRIBUTING.md) for contributing details.\n\nThe MIT License (MIT). Please see [LICENSE](LICENSE) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/middlewares/json-exception-handler.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-ga]: https://github.com/middlewares/json-exception-handler/workflows/testing/badge.svg\n[ico-downloads]: https://img.shields.io/packagist/dt/middlewares/json-exception-handler.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/middlewares/json-exception-handler\n[link-downloads]: https://packagist.org/packages/middlewares/json-exception-handler\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiddlewares%2Fjson-exception-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiddlewares%2Fjson-exception-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiddlewares%2Fjson-exception-handler/lists"}