the whole shebang
This commit is contained in:
46
vendor/filp/whoops/examples/example-ajax-only.php
vendored
Normal file
46
vendor/filp/whoops/examples/example-ajax-only.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Whoops - php errors for cool kids
|
||||
* @author Filipe Dobreira <http://github.com/filp>
|
||||
*
|
||||
* Run this example file with the PHP 5.4 web server with:
|
||||
*
|
||||
* $ cd project_dir
|
||||
* $ php -S localhost:8080
|
||||
*
|
||||
* and access localhost:8080/example/example-ajax-only.php through your browser
|
||||
*
|
||||
* Or just run it through apache/nginx/what-have-yous as usual.
|
||||
*/
|
||||
|
||||
namespace Whoops\Example;
|
||||
use Whoops\Run;
|
||||
use Whoops\Handler\PrettyPageHandler;
|
||||
use Whoops\Handler\JsonResponseHandler;
|
||||
use RuntimeException;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$run = new Run;
|
||||
|
||||
// We want the error page to be shown by default, if this is a
|
||||
// regular request, so that's the first thing to go into the stack:
|
||||
$run->pushHandler(new PrettyPageHandler);
|
||||
|
||||
// Now, we want a second handler that will run before the error page,
|
||||
// and immediately return an error message in JSON format, if something
|
||||
// goes awry.
|
||||
$jsonHandler = new JsonResponseHandler;
|
||||
|
||||
// Make sure it only triggers for AJAX requests:
|
||||
$jsonHandler->onlyForAjaxRequests(true);
|
||||
|
||||
// You can also tell JsonResponseHandler to give you a full stack trace:
|
||||
// $jsonHandler->addTraceToOutput(true);
|
||||
|
||||
// And push it into the stack:
|
||||
$run->pushHandler($jsonHandler);
|
||||
|
||||
// That's it! Register Whoops and throw a dummy exception:
|
||||
$run->register();
|
||||
throw new RuntimeException("Oh fudge napkins!");
|
36
vendor/filp/whoops/examples/example-silex.php
vendored
Normal file
36
vendor/filp/whoops/examples/example-silex.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Whoops - php errors for cool kids
|
||||
* @author Filipe Dobreira <http://github.com/filp>
|
||||
*
|
||||
* NOTE: Requires silex/silex, can be installed with composer
|
||||
* within this project using the --dev flag:
|
||||
*
|
||||
* $ composer install --dev
|
||||
*
|
||||
* Run this example file with the PHP 5.4 web server with:
|
||||
*
|
||||
* $ cd project_dir
|
||||
* $ php -S localhost:8080
|
||||
*
|
||||
* and access localhost:8080/examples/example-silex.php through your browser
|
||||
*
|
||||
* Or just run it through apache/nginx/what-have-yous as usual.
|
||||
*/
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use Whoops\Provider\Silex\WhoopsServiceProvider;
|
||||
use Silex\Application;
|
||||
|
||||
$app = new Application;
|
||||
$app['debug'] = true;
|
||||
|
||||
if($app['debug']) {
|
||||
$app->register(new WhoopsServiceProvider);
|
||||
}
|
||||
|
||||
$app->get('/', function() use($app) {
|
||||
throw new RuntimeException("Oh no!");
|
||||
});
|
||||
|
||||
$app->run();
|
63
vendor/filp/whoops/examples/example.php
vendored
Normal file
63
vendor/filp/whoops/examples/example.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Whoops - php errors for cool kids
|
||||
* @author Filipe Dobreira <http://github.com/filp>
|
||||
*
|
||||
* Run this example file with the PHP 5.4 web server with:
|
||||
*
|
||||
* $ cd project_dir
|
||||
* $ php -S localhost:8080
|
||||
*
|
||||
* and access localhost:8080/example/example.php through your browser
|
||||
*
|
||||
* Or just run it through apache/nginx/what-have-yous as usual.
|
||||
*/
|
||||
|
||||
namespace Whoops\Example;
|
||||
use Whoops\Run;
|
||||
use Whoops\Handler\PrettyPageHandler;
|
||||
use Exception as BaseException;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
class Exception extends BaseException {}
|
||||
|
||||
$run = new Run;
|
||||
$handler = new PrettyPageHandler;
|
||||
|
||||
// Add a custom table to the layout:
|
||||
$handler->addDataTable('Ice-cream I like', array(
|
||||
'Chocolate' => 'yes',
|
||||
'Coffee & chocolate' => 'a lot',
|
||||
'Strawberry & chocolate' => 'it\'s alright',
|
||||
'Vanilla' => 'ew'
|
||||
));
|
||||
|
||||
$run->pushHandler($handler);
|
||||
|
||||
// Example: tag all frames inside a function with their function name
|
||||
$run->pushHandler(function($exception, $inspector, $run) {
|
||||
|
||||
$inspector->getFrames()->map(function($frame) {
|
||||
|
||||
if($function = $frame->getFunction()) {
|
||||
$frame->addComment("This frame is within function '$function'", 'cpt-obvious');
|
||||
}
|
||||
|
||||
return $frame;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$run->register();
|
||||
|
||||
function fooBar() {
|
||||
throw new Exception("Something broke!");
|
||||
}
|
||||
|
||||
function bar()
|
||||
{
|
||||
fooBar();
|
||||
}
|
||||
|
||||
bar();
|
Reference in New Issue
Block a user