Skip to content

Instantly share code, notes, and snippets.

@hugomrdias
Last active December 14, 2015 23:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save hugomrdias/5169713 to your computer and use it in GitHub Desktop.
Save hugomrdias/5169713 to your computer and use it in GitHub Desktop.
Damnit for Laravel 3
/**
* 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('whoops');
}
@hugomrdias
Copy link
Author

yeah @kapooostin whoops does not handle views errors but it shouldn't give that output either..
its a blade thing and the way it uses eval and cache to build the view but it should output a standard php error.

do you have L3 latest version ? taylor improved the blade's error handling before changing development completely to L4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment