Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zeuxisoo/php-slim-whoops
PHP whoops error on slim framework
https://github.com/zeuxisoo/php-slim-whoops
middleware php php-slim-whoops slim-framework whoops whoops-errors
Last synced: 3 months ago
JSON representation
PHP whoops error on slim framework
- Host: GitHub
- URL: https://github.com/zeuxisoo/php-slim-whoops
- Owner: zeuxisoo
- Created: 2013-04-15T07:51:49.000Z (over 11 years ago)
- Default Branch: 0.7.x
- Last Pushed: 2024-04-22T15:18:04.000Z (7 months ago)
- Last Synced: 2024-06-18T12:38:03.952Z (5 months ago)
- Topics: middleware, php, php-slim-whoops, slim-framework, whoops, whoops-errors
- Language: PHP
- Size: 215 KB
- Stars: 131
- Watchers: 4
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-slim - Slim Whoops - PHP whoops error on slim framework. (Middlewares)
README
# Slim whoops
PHP whoops error on slim framework
## Status
[![Build Status](https://github.com/zeuxisoo/php-slim-whoops/workflows/Tests/badge.svg?branch=0.7.x)](https://github.com/zeuxisoo/php-slim-whoops/actions?query=branch:0.7.x)
[![Coverage Status](https://coveralls.io/repos/github/zeuxisoo/php-slim-whoops/badge.svg)](https://coveralls.io/github/zeuxisoo/php-slim-whoops)
[![Downloads this Month](https://img.shields.io/packagist/dm/zeuxisoo/slim-whoops.svg)](https://packagist.org/packages/zeuxisoo/slim-whoops)
[![Latest Stable Version](https://poser.pugx.org/zeuxisoo/slim-whoops/v/stable)](https://github.com/zeuxisoo/php-slim-whoops/releases)## Installation
Install the composer
```console
curl -sS https://getcomposer.org/installer | php
```
Edit `composer.json`| Slim | Whoops | Version | Global Mode | PHP DI |
| ---- | --------- | ------- | ----------- | ------ |
| 1 | n/a | 0.1.* | no | no |
| 2 | 1.* | 0.3.* | no | no |
| 3 | <= 1.* | 0.4.* | no | no |
| 3 | >= 2.* | 0.5.* | no | no |
| 3 | >= 2.* | 0.6.* | yes | yes |
| 4 | >= 2.* | 0.7.* | no | no |For `Slim framework 4`, The `composer.json` will looks like
```json
{
"require": {
"zeuxisoo/slim-whoops": "0.7.*"
}
}
```
Now, `install` or `update` the dependencies
```console
composer install
```
## Basic UsageAdd to middleware with default settings
```php
$app->add(new Zeuxisoo\Whoops\Slim\WhoopsMiddleware());
```Or you can pass more settings to the `WhoopsMiddleware`
```php
$app->add(new Zeuxisoo\Whoops\Slim\WhoopsMiddleware([
'enable' => true,
'editor' => 'sublime',
'title' => 'Custom whoops page title',
]));
```
## Custom Editor StringIf your editor do not included in [default editor list][2], you can custom it like
```php
$app->add(new Zeuxisoo\Whoops\Slim\WhoopsMiddleware([
'editor' => function($file, $line) {
return "http://localhost:8091?message=%file:%line";
}
]));
```
## Custom Handler UsageIn this usage, you can make your own handler for whoops, like:
```php
$simplyErrorHandler = function($exception, $inspector, $run) {
$message = $exception->getMessage();
$title = $inspector->getExceptionName();echo "{$title} -> {$message}";
exit;
};
```
And then pass it to the `WhoopsMiddleware`:
```php
new Zeuxisoo\Whoops\Slim\WhoopsMiddleware([], [$simplyErrorHandler]);
```
## Important NoteVersion `0.3.0` or above version
- The `whoops` library is installed by default base on the [Whoops Framework Integration Document][1]
Version `0.2.0`
- You must to install the `whoops` library manually.
[1]: https://github.com/filp/whoops/blob/master/docs/Framework%20Integration.md#contributing-an-integration-with-a-framework "Whoops Framework Integration Document"
[2]: https://github.com/filp/whoops/blob/master/docs/Open%20Files%20In%20An%20Editor.md#open-files-in-an-editor "Whoops Framework Open Files In An Editor"