-
-
Save kapooostin/5430136 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Thanks to @philsturgeon for pointing this package | |
* and Filipe Dobreira "https://github.com/filp" for creating it ^^ | |
* Github : https://github.com/filp/whoops | |
* How to: | |
* Step 1 : Setup composer for Laravel 3 | |
* Step 2 : Add this code to your application/start.php or anywhere u like | |
* as long its after laravel registers its own error handlers | |
* so NOT in : index.php, paths.php or laravel/** | |
* | |
* Use IoC to setup your whoops instance as singleton and then you can add special | |
* handlers specific for your needs anywhere | |
* inside your app code (controller, models, etc...) freaking awesome. | |
* Ex: | |
* $damnit = IoC::resolve('whoops'); | |
* $damnit->pushHandler($some-handler-you-made-check-the-whoops-repo-for-examples); | |
* | |
* You can also add datatables for a handler like this | |
* $damnit = IoC::resolve('whoops'); | |
* $handlers = $damnit->getHandlers(); | |
* $handlers[0]->addDataTable('Ice-cream I like', array( | |
* 'Chocolate' => 'yes', | |
* 'Coffee & chocolate' => 'a lot', | |
* 'Strawberry & chocolate' => 'it\'s alright', | |
* 'Vanilla' => 'ew' | |
* ) | |
* ); | |
* | |
* Also check out the second handler im not gonna explain it but its also pretty cool. | |
*/ | |
/** | |
* Custom error handling with whoops | |
*/ | |
if (!IoC::registered('whoops')) { | |
IoC::singleton('whoops', function ($from = true) { | |
$run = new Whoops\Run; | |
$handler = new Whoops\Handler\PrettyPageHandler; | |
$run->pushHandler($handler); | |
// Example: tag all frames with a comment | |
// Hint: Frames are the code preview for each stack row | |
$run->pushHandler(function ($exception, $inspector, $run) { | |
$frames = $inspector->getFrames(); | |
foreach ($frames as $i => $frame) { | |
$frame->addComment('This is frame number ' . $i, 'example'); | |
if ($function = $frame->getFunction()) { | |
$frame->addComment("This frame is within function '$function'", 'cpt-obvious'); | |
} | |
} | |
} | |
); | |
$run->register(); | |
return $run; | |
} | |
); | |
} | |
if (Config::get('error.detail')){ | |
$damnit = IoC::resolve('houses.error'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment