Daniel ab1334c0cf the whole shebang | 10 years ago | |
---|---|---|
.. | ||
examples | 10 years ago | |
src | 10 years ago | |
tests | 10 years ago | |
.gitignore | 10 years ago | |
.travis.yml | 10 years ago | |
LICENSE.md | 10 years ago | |
README.md | 10 years ago | |
composer.json | 10 years ago | |
composer.lock | 10 years ago | |
phpunit.xml.dist | 10 years ago |
php errors for cool kids
whoops is an error handler base/framework for PHP. Out-of-the-box, it provides a pretty error interface that helps you debug your web projects, but at heart it's a simple yet powerful stacked error handling system.
pretty-template.php
, for now...)Install Composer and place the executable somewhere in your $PATH
(for the rest of this README,
I'll reference it as just composer
)
Add filp/whoops
to your project's `composer.json:
{
"require": {
"filp/whoops": "1.*"
}
}
$ cd my_project
$ composer install
And you're good to go! Have a look at the example files in examples/
to get a feel for how things work.
I promise it's really simple!
Initial API documentation of the whoops library is available here: https://github.com/filp/whoops/wiki/API-Documentation
whoops comes packaged with a Silex Service Provider: Whoops\Provider\Silex\WhoopsServiceProvider
. Using it
in your existing Silex project is easy:
require 'vendor/autoload.php';
use Silex\Application;
// ... some awesome code here ...
if($app['debug']) {
$app->register(new Whoops\Provider\Silex\WhoopsServiceProvider);
}
// ...
$app->run();
And that's about it. By default, you'll get the pretty error pages if something goes awry in your development
environment, but you also have full access to the whoops library, obviously. For example, adding a new handler
into your app is as simple as extending whoops
:
$app['whoops'] = $app->extend('whoops', function($whoops) {
$whoops->pushHandler(new DeleteWholeProjectHandler);
return $whoops;
});
whoops comes packaged with a Phalcon Service Provider: Whoops\Provider\Phalcon\WhoopsServiceProvider
. Using it
in your existing Phalcon project is easy. The provider uses the default Phalcon DI unless you pass a DI instance into the constructor.
new Whoops\Provider\Phalcon\WhoopsServiceProvider;
// --- or ---
$di = Phalcon\DI\FactoryDefault;
new Whoops\Provider\Phalcon\WhoopsServiceProvider($di);
If you're using Laravel 4, as of this commit to laravel/framework, you're already using Whoops! Yay!
User @hdias contributed a simple guide/example to help you integrate whoops with Laravel 3's IoC container, available at:
https://gist.github.com/hdias/5169713#file-start-php
User @zsilbi contributed a provider for ZF2 integration, available in the following location:
https://github.com/filp/whoops/tree/master/src/Whoops/Provider/Zend
Instructions:
'modules' => array(
'Whoops',
'Application'
)
return array(
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'json_exceptions' => array(
'display' => true,
'ajax_only' => true,
'show_trace' => true
)
),
);
When using the pretty error page feature, whoops comes with the ability to open referenced files directly in your IDE or editor.
<?php
use Whoops\Handler\PrettyPageHandler;
$handler = new PrettyPageHandler;
$handler->setEditor('sublime');
The following editors are currently supported by default.
sublime
- Sublime Text 2emacs
- Emacstextmate
- Textmatemacvim
- MacVimxdebug
- xdebug (uses xdebug.file_link_format)Adding your own editor is simple:
$handler->setEditor(function($file, $line) {
return "whatever://open?file=$file&line=$line";
});
whoops currently ships with the following built-in handlers, available in the Whoops\Handler
namespace:
PrettyPageHandler
- Shows a pretty error page when something goes pants-upCallbackHandler
- Wraps a closure or other callable as a handler. You do not need to use this handler explicitly, whoops will automatically wrap any closure or callable you pass to Whoops\Run::pushHandler
JsonResponseHandler
- Captures exceptions and returns information on them as a JSON string. Can be used to, for example, play nice with AJAX requests.If you want to give me some feedback or make a suggestion, send me a message through twitter: @imfilp
If you want to get your hands dirty, great! Here's a couple of steps/guidelines:
$ git clone git@github.com:filp/whoops.git
$ cd whoops
$ composer install --dev
$ git checkout -b feature/flames-on-the-side
tests/
).PSR-2
.If you don't want to go through all this, but still found something wrong or missing, please let me know, and/or open a new issue report so that I or others may take care of it.
This library was primarily developed by Filipe Dobreira.
A lot of awesome fixes and enhancements were also sent in by contributors, which you can find in this page right here.