Home

Awesome

Slim whoops

PHP whoops error on slim framework

Status

Build Status Coverage Status Downloads this Month Latest Stable Version

Installation

Install the composer

curl -sS https://getcomposer.org/installer | php

Edit composer.json

SlimWhoopsVersionGlobal ModePHP DI
1n/a0.1.*nono
21.*0.3.*nono
3<= 1.*0.4.*nono
3>= 2.*0.5.*nono
3>= 2.*0.6.*yesyes
4>= 2.*0.7.*nono

For Slim framework 4, The composer.json will looks like

{
    "require": {
        "zeuxisoo/slim-whoops": "0.7.*"
    }
}

Now, install or update the dependencies

composer install

Basic Usage

Add to middleware with default settings

$app->add(new Zeuxisoo\Whoops\Slim\WhoopsMiddleware());

Or you can pass more settings to the WhoopsMiddleware

$app->add(new Zeuxisoo\Whoops\Slim\WhoopsMiddleware([
    'enable' => true,
    'editor' => 'sublime',
    'title'  => 'Custom whoops page title',
]));

Custom Editor String

If your editor do not included in default editor list, you can custom it like

$app->add(new Zeuxisoo\Whoops\Slim\WhoopsMiddleware([
    'editor' => function($file, $line) {
        return "http://localhost:8091?message=%file:%line";
    }
]));

Custom Handler Usage

In this usage, you can make your own handler for whoops, like:

$simplyErrorHandler = function($exception, $inspector, $run) {
    $message = $exception->getMessage();
    $title   = $inspector->getExceptionName();

    echo "{$title} -> {$message}";
    exit;
};

And then pass it to the WhoopsMiddleware:

new Zeuxisoo\Whoops\Slim\WhoopsMiddleware([], [$simplyErrorHandler]);

Important Note

Version 0.3.0 or above version

Version 0.2.0