Not without a significant violation of the principles of structure (I will tell you how to do it below if you are still interested).
There are several things that make this difficult to achieve. It is simple enough to disable the default error and exception handlers
set_error_handler(null); set_exception_handler(null);
but that leaves you with two major hurdles.
First, Laravel registers a shutdown handler as part of its self-tuning, and this break function will look for the last error, and if it was a fatal error, manually call the exception handling code. There is no easy way to uninstall the shutdown function .
Secondly, the main Laravel application handler is as follows:
#File: vendor/laravel/framework/src/Illuminate/Foundation/Application.php public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) { try { $this->refreshRequest($request = Request::createFromBase($request)); $this->boot(); return $this->dispatch($request); } catch (\Exception $e) { if ($this->runningUnitTests()) throw $e; return $this['exception']->handleException($e); } }
That is, if the application code throws an exception, Laravel catches it and manually calls the handleException exception handleException (which triggers the standard Laravel exception handling). Unable to let PHP handle the fatal exception that occurs in your application, Laravel blocks this from ever happening.
The part where I will tell you how to do what you want
All of this means that we must replace the main Laravel application with our own. In bootstrap/start.php following line exists
#File: bootstrap/start.php $app = new Illuminate\Foundation\Application;
Replace it with the following
ini_set('display_errors','1'); class MyApplication extends Illuminate\Foundation\Application { function startExceptionHandling() { //do nothing } public function handle(Symfony\Component\HttpFoundation\Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) { $this->refreshRequest($request = Request::createFromBase($request)); $this->boot(); return $this->dispatch($request); } } $app = new MyApplication;
The first thing we do is set the ini mapping display errors to 1 . This ensures that errors are displayed in the browser.
Next, we define a new application class that extends the class of the real application.
Finally, we replace the real Laravel $app object with the object created by our class.
In our application class, we will close startExceptionHandling . This prevents Laravel from setting custom exceptions, errors, and shutdowns. We also define handle to remove loading / sending the application from try / catch. This is the most fragile part of the process and may look different depending on your version of Laravel.
Final Warnings
If the handle method changes in a future version of Laravel, it will break.
If custom packages rely on the addition of custom exception handlers, they can break.
I would recommend staying away from this like nothing but a temporary debugging technique.