{"id":21947649,"url":"https://github.com/soooldier/hyperf-whoops","last_synced_at":"2025-04-22T23:43:20.436Z","repository":{"id":57055793,"uuid":"194996756","full_name":"soooldier/hyperf-whoops","owner":"soooldier","description":null,"archived":false,"fork":false,"pushed_at":"2019-07-03T16:52:16.000Z","size":9,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-29T20:03:48.629Z","etag":null,"topics":["hyperf"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soooldier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-03T06:53:33.000Z","updated_at":"2020-12-16T10:06:20.000Z","dependencies_parsed_at":"2022-08-24T14:00:29.563Z","dependency_job_id":null,"html_url":"https://github.com/soooldier/hyperf-whoops","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soooldier%2Fhyperf-whoops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soooldier%2Fhyperf-whoops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soooldier%2Fhyperf-whoops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soooldier%2Fhyperf-whoops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soooldier","download_url":"https://codeload.github.com/soooldier/hyperf-whoops/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250343754,"owners_count":21415035,"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":["hyperf"],"created_at":"2024-11-29T05:09:01.822Z","updated_at":"2025-04-22T23:43:20.422Z","avatar_url":"https://github.com/soooldier.png","language":"PHP","readme":"# hyperf-whoops\n\n让hyperf支持whoops显示异常信息\n\n# Features\n\n* 开箱即用\n\n# How to use\n\n```shell\ncomposer require soooldier/hyperf-whoops\n```\n\n# Api\n- [hyperf-whoops](#hyperf-whoops)\n- [Features](#Features)\n- [How to use](#How-to-use)\n- [Api](#Api)\n- [Contents](#Contents)\n  - [getHtmlOutput](#getHtmlOutput)\n  - [getPlainTextOutput](#getPlainTextOutput)\n  - [getJsonOutput](#getJsonOutput)\n- [Example](#Example)\n- [ChangeLog](#ChangeLog)\n\n# Contents\n\n## getHtmlOutput\n`$whoops-\u003egetHtmlOutput()`\n\n## getPlainTextOutput\n`$whoops-\u003egetPlainTextOutput()`\n\n## getJsonOutput\n`$whoops-\u003egetJsonOutput()`\n\n# Example\n\n```php\nclass AppExceptionHandler extends ExceptionHandler\n{\n    /**\n     * @var ContainerInterface\n     */\n    private $container;\n\n    /**\n     * @var StdoutLoggerInterface\n     */\n    private $logger;\n\n    public function __construct(StdoutLoggerInterface $logger, ContainerInterface $container)\n    {\n        $this-\u003elogger = $logger;\n        $this-\u003econtainer = $container;\n    }\n\n    public function handle(Throwable $throwable, ResponseInterface $response)\n    {\n        $whoops = $this-\u003econtainer-\u003eget('whoops');\n        $content = $whoops-\u003egetHtmlOutput($throwable); // 获取html格式输出，日志最详细\n        // $content = $whoops-\u003egetJsonOutput($throwable); // 获取json格式输出，通常配合ajax使用\n        // $content = $whoops-\u003egetPlainTextOutput($throwable); // 文本格式输出，通常记日志\n        return $response-\u003ewithStatus(500)-\u003ewithBody(new SwooleStream($content));\n    }\n\n    public function isValid(Throwable $throwable): bool\n    {\n        return true;\n    }\n}\n```\n\n# ChangeLog\n\n* v1.0.0 第一版\n* v1.0.1 修复相同协程内数据污染问题","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoooldier%2Fhyperf-whoops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoooldier%2Fhyperf-whoops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoooldier%2Fhyperf-whoops/lists"}