{"id":13669248,"url":"https://github.com/thephpleague/booboo","last_synced_at":"2025-04-27T01:32:54.507Z","repository":{"id":24122303,"uuid":"27510788","full_name":"thephpleague/booboo","owner":"thephpleague","description":"A modern error handler capable of logging and formatting errors in a variety of ways.","archived":true,"fork":false,"pushed_at":"2024-04-28T18:22:21.000Z","size":167,"stargazers_count":337,"open_issues_count":8,"forks_count":25,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-04-19T02:23:49.899Z","etag":null,"topics":[],"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/thephpleague.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-03T22:24:57.000Z","updated_at":"2025-02-11T16:21:01.000Z","dependencies_parsed_at":"2024-06-18T12:24:44.931Z","dependency_job_id":"24e6ca5c-f95a-46d5-895f-1c2368700e2d","html_url":"https://github.com/thephpleague/booboo","commit_stats":{"total_commits":142,"total_committers":14,"mean_commits":"10.142857142857142","dds":0.1619718309859155,"last_synced_commit":"c94b8b0ed9c7675767860a7dd9146882349eff11"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thephpleague%2Fbooboo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thephpleague%2Fbooboo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thephpleague%2Fbooboo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thephpleague%2Fbooboo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thephpleague","download_url":"https://codeload.github.com/thephpleague/booboo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250899300,"owners_count":21504866,"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-08-02T08:01:07.548Z","updated_at":"2025-04-27T01:32:52.670Z","avatar_url":"https://github.com/thephpleague.png","language":"PHP","funding_links":[],"categories":["PHP","调试和性能( Debugging and Profiling )","类库"],"sub_categories":["错误/异常"],"readme":"# BooBoo\n\n## Quality\n\n[![Build Status](https://travis-ci.org/thephpleague/booboo.svg?branch=master)](https://travis-ci.org/thephpleague/booboo)\n[![Code Climate](https://codeclimate.com/github/thephpleague/booboo/badges/gpa.svg)](https://codeclimate.com/github/thephpleague/booboo)\n[![Test Coverage](https://codeclimate.com/github/thephpleague/booboo/badges/coverage.svg)](https://codeclimate.com/github/thephpleague/booboo)\n\n## Purpose\nAn error handler for PHP that allows for the execution of handlers and formatters for viewing and managing errors in\ndevelopment and production. Because we all make mistakes.\n\n## Installation\n\nThis library requires PHP 5.4 or later. One test is skipped against HHVM, but all others pass. BooBoo will support PHP 7 in a future release.\n\nIt is recommended that you install this library using Composer.\n\n```\n$ composer require league/booboo\n```\n\nBooBoo is compliant with [PSR-1][], [PSR-2][], [PSR-3][] and [PSR-4][]. If you notice compliance oversights, please\nsend a patch via pull request.\n\n[PSR-1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md\n[PSR-2]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md\n[PSR-3]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md\n[PSR-4]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md\n\n## Dependencies\n\nBooBoo relies upon and requires the following dependencies:\n\n* `psr/log` - A PSR-3 compliant interface for logging.\n\nNo other dependencies are required. The maintainer recommends installing [monolog][] for logging.\n\n[monolog]: https://github.com/Seldaek/monolog\n\n## Advantages Over Existing Solutions\n\nBooBoo is designed to help make development easier while providing an integrated solution that can be deployed to\nyour production environment. BooBoo offers the following advantages:\n\n### Errors are non-blocking by default\n\nSome solutions throw exceptions for all errors, causing every notice to become a fatal error. BooBoo doesn't do this.\nRather than raise an exception for non-fatal errors, we display the error to you in a way that makes sense and lets the\nprogram continue running. An `E_NOTICE` shouldn't become an exception.\n\nThe Runner object offers a method for forcing all errors to be blocking, should you wish to throw exceptions for more minor errors. This is turned off by default.\n\n### BooBoo won't end up in your stack trace\n\nBecause we don't throw an exception by default, we don't generate a stack trace for minor errors. This means BooBoo won't show up in your logs, and when it handles an exception generated elsewhere, it isn't appended there, either.\n\n### BooBoo is built for logging\n\nThis solution is designed with logging in mind, so that you can plug and play a [PSR-3][] compliant logging solution in and\ngo. BooBoo is sensitive enough to log errors, warnings and notices as such; exceptions are logged as critical, and\n`E_STRICT`/`E_DEPRECATED` warnings are logged as info. Handlers run even if formatting is disabled, so your logging will\nalways be on, even in production.\n\n[PSR-3]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md\n\n### BooBoo is designed for extension\n\nWe can't possibly think through all your use cases, but we know you can. That's why we use standard interfaces to make\nit easy to extend and enhance the BooBoo functionality. (We also love pull requests; please share your\ninnovations!)\n\n### BooBoo is actively maintained\n\nPHP is changing every year, and BooBoo will change along with it. \n\n## Getting Started\n\n### Instantiation\n\nThe main object that you need to instantiate is `League\\BooBoo\\BooBoo`. This object takes care of setting the error\nhandler, as well as handling errors and exceptions. It takes optional arguments during construction for handlers and\nformatters.\n\n```php\n\u003c?php\n\n$booboo = new League\\BooBoo\\BooBoo();\n$booboo-\u003eregister(); // Registers the handlers\n```\n\nIt's very important to call `BooBoo::register()` or the object won't register itself as PHP's error handler.\n\n### Formatters are very important!\n\nWhen you're developing, you want to view errors in the browser. In order to do this, you must provide a formatter.\nWithout a formatter, the system won't intelligently know how to display the errors. As a result, the Runner will throw\nan exception and won't register the error handlers.\n\nThe library ships with four formatters for your convenience:\n\n* `HtmlFormatter` - Formats errors just like PHP's error formatting.\n* `HtmlTableFormatter` - Formats errors and exceptions similar to Xdebug, wth a full stack trace, even for errors.\n* `JsonFormatter` - Perfect for displaying errors to an API.\n* `CommandLineFormatter` - Working with the command line? This will produce pretty command-line errors.\n* `NullFormatter` - This formatter simply silences all errors. You can pass this when display_errors = Off.\nAdding a formatter is easy:\n\n```php\n\u003c?php\n\n$booboo-\u003epushFormatter(new League\\BooBoo\\Formatter\\HtmlFormatter());\n```\n\n### Controlling which formatter does the formatting\n\nThere may be times that you want certain formatters to handle the formatting for particular errors, and others to handle\nthe formatting for other error types. Formatters support this.\n\nFor example, if you want all errors of warning or higher to show in the browser, but errors that are below this level\nto be ignored, you can configure the formatters to handle this scenario as such:\n\n```php\n\u003c?php\n\n$html = new League\\BooBoo\\Formatter\\HtmlFormatter();\n$null = new League\\BooBoo\\Formatter\\NullFormatter();\n\n$html-\u003esetErrorLimit(E_ERROR | E_WARNING | E_USER_ERROR | E_USER_WARNING);\n$null-\u003esetErrorLimit(E_ALL);\n\n$booboo-\u003epushFormatter($null);\n$booboo-\u003epushFormatter($html);\n```\n\n### Formatters and handlers are a stack\n\nFormatters and handlers are treated as a stack. This means that the last item in will be the first item out. This is\nvery important when dealing with formatters that only handle certain errors!\n\nFor example, in the example above, we have one formatter limited to errors and warnings, and the other formatting all\nerror types. If we insert the HTML handler first, it will be run last; this would cause the NullFormatter to format all\nerrors, and we would get no output.\n\n### Handlers\n\nRegardless of whether or not you want to format the error (or even output it to the screen), you may want to handle it\nin some way, such as logging it. BooBoo provides a way to handle errors, and provides a built-in [PSR-3][] compatible\nlogging handler.\n\n[PSR-3]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md\n\nYou can implement the HandlerInterface to create your own handlers. Handlers are run regardless of whether or not\ndisplay_errors is true. Unlike formatters, you cannot direct handlers to ignore certain errors; it's assumed that you\ncan handle this with the services that handlers work through.\n\n# Documentation\n\n[Check out the documentation here](http://booboo.thephpleague.com/)\n\n# Security\n\nIf you have identified a security issue, please email brandon@brandonsavage.net directly. Do not file an issue as they are public!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthephpleague%2Fbooboo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthephpleague%2Fbooboo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthephpleague%2Fbooboo/lists"}