https://github.com/thecodingmachine/whoops-stackphp
This package contains a StackPHP middleware that catches all exceptions and redirects those to the Whoops error handling library.
https://github.com/thecodingmachine/whoops-stackphp
Last synced: 9 months ago
JSON representation
This package contains a StackPHP middleware that catches all exceptions and redirects those to the Whoops error handling library.
- Host: GitHub
- URL: https://github.com/thecodingmachine/whoops-stackphp
- Owner: thecodingmachine
- Created: 2014-12-17T16:26:17.000Z (about 11 years ago)
- Default Branch: 2.0
- Last Pushed: 2016-04-20T15:33:57.000Z (almost 10 years ago)
- Last Synced: 2025-04-11T18:59:52.936Z (10 months ago)
- Language: PHP
- Size: 3.91 KB
- Stars: 14
- Watchers: 17
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Whoops middleware for StackPHP
==============================
This package contains a [StackPHP middleware](http://stackphp.com/) that catches all exceptions and redirects those to the [Whoops error handling library](http://filp.github.io/whoops/).
Installation
------------
Through [Composer](https://getcomposer.org/) as [mouf/whoops-stackphp](https://packagist.org/packages/mouf/whoops-stackphp).
Usage
-----
Simply use the `WhoopsMiddleWare` class in your middleware stack:
```php
use Whoops\StackPhp\WhoopsMiddleWare;
$router = new WhoopsMiddleWare(
new MyOtherRouter(
new YetAnotherRouter()));
```
If an exception is thrown, or an error is raised, Whoops will display a nice error message:
[](http://filp.github.io/whoops/demo/)
The `WhoopsMiddleWare` constructor accepts 3 parameters:
```php
public function __construct(HttpKernelInterface $router, $catchExceptions = true, $catchErrors = true);
```
- **$router**: this is the next router to be called on the Stack
- **$catchExceptions**: Set to true to catch exception. Set to false to ignore exceptions (for production servers)
- **$catchErrors**: Set to true to catch raised errors. Set to false to ignore raised errors (for production servers)
Note: `$catchExceptions` and `$catchErrors` can be passed a boolean, a callable (that returns a boolean) or a [ConditionInterface](http://mouf-php.com/packages/mouf/utils.common.conditioninterface/README.md) that evaluates to true or false.