Custom error handling flight php using whoops package

January 01, 2019

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.


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);

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

Subscribe to My Newsletter

Thank you for your interest in my blog. Sign up to my newsletter to stay current on the latest news and information me and to be the first to see new blog posts.