https://github.com/swoft-cloud/swoft-whoops
[READ ONLY] Swoft errors for cool kids by filp/whoops
https://github.com/swoft-cloud/swoft-whoops
swoft swoft-component swoft-errors swoft-whoops
Last synced: 2 months ago
JSON representation
[READ ONLY] Swoft errors for cool kids by filp/whoops
- Host: GitHub
- URL: https://github.com/swoft-cloud/swoft-whoops
- Owner: swoft-cloud
- License: apache-2.0
- Created: 2018-03-14T15:23:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-05-07T16:53:03.000Z (about 4 years ago)
- Last Synced: 2025-04-19T17:53:57.623Z (2 months ago)
- Topics: swoft, swoft-component, swoft-errors, swoft-whoops
- Language: PHP
- Homepage: https://www.swoft.org
- Size: 20.5 KB
- Stars: 4
- Watchers: 8
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Swoft Whoops
[](https://packagist.org/packages/swoft/whoops)
[](https://secure.php.net/)
[](https://www.swoft.org/docs)
[](https://github.com/swoft-cloud/swoft/blob/master/LICENSE)Swoft http errors for cool kids by [filp/whoops](https://github.com/filp/whoops)
## Install
- composer command
```bash
composer require --dev swoft/whoops
```## Usage
- Method 1
Use the `Swoft\Whoops\WhoopsMiddleware` as an global middleware(`app/bean.php`):
```php
'httpDispatcher' => [
// Add global http middleware
'middlewares' => [
// Notice: Please add to the first place
\Swoft\Whoops\WhoopsMiddleware::class,
],
],
```- Method 2
Change the `App\Exception\Handler\HttpExceptionHandler` class:
```php
getRequest();
if ($request->getUriPath() === '/favicon.ico') {
return $response->withStatus(404);
}// Log
CLog::error($e->getMessage());// Debug is false
if (!APP_DEBUG) {
return $response
->withStatus(500)
->withContent($e->getMessage());
}// Debug is true
$whoops = bean(WhoopsHandler::class);
$content = $whoops->run($e, $request);return $response->withContent($content)->withContentType(ContentType::HTML);;
}
}
```## LICENSE
The Component is open-sourced software licensed under the [Apache license](LICENSE).