3

I'd like to insert a code snippet into Laravel's error pages, but I can't figure out how to modify or capture the output.

This filthy hack seems to work, but the snippet is inserted before any page code.

// In laravel/app/start/global.php

App::error(function (Exception, $exception, $code)
{
    echo '<script src="//localhost:35729/livereload.js"></script>';
});
joemaller
  • 19,579
  • 7
  • 67
  • 84

1 Answers1

1

The error pages are in resources/views/errors. You can then simply add whatever you want inside those file by naming them with the status code like 503.blade.php.

You can even make a base error page and the other view extends this one.

You can also take a look at the \App\Exceptions\Handler class in the report method, you can check Exceptions that have been thrown there.

Elie Faës
  • 3,215
  • 1
  • 25
  • 41