Custom error handling flight php using whoops package

undefined

Flightphp is easy, simple, extensible framework for PHP and it useful for build small php web app. It can be use for creating rest api or event a web blog. For more you can visit this link.

When developing an app, especially php app will always be faced with some error. For that to make this error easy to track wee need to read error message correctly.

One of good solution is using whoop handler. I look like this, good ui and make we can more understand what's wrong with our code.

undefined

So here how you can integrate whoop package into your app that build using flight php.

First install whoop dependency into your app.

composer require filp/whoops

And now integrate flight php using this snippet.

Flight::map('error', function(\Exception $e){
	$whoops = new \Whoops\Run;
	$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
	$whoops->register();
	$whoops->handleException($e);
});
Flight::start();

Yes just that's all. Hope this can help you.