I would like to completely turn off error reporting, because we have very old code that we still need to fix, but for now it works (yes, I don't like it either). We cannot fix everything in a few days, so we just need to suppress warnings and exceptions, as we always did.
The real problem is that it already throws an exception on a simple lazy error like (because var is not defined)
if(!$var) { // do whatever }
tried to
APP_DEBUG = false
APP_LOG_LEVEL = emergency
display_errors(false); set_error_handler(null); set_exception_handler(null);
But it still shows an ErrorException
Undefined variable: script_name_vars_def
edit : code works like this
web.php
Route::any('/someroute', ' somecontroller@controllerFunc ');
somecontroller.php
public controllerFunc() { ob_start(); require '/old_index.php'; $html = ob_get_clean(); return response($html); }
Thus, we use Laravel routing without having to rewrite old code immediately.
I know that I can very easily fix this warning, but there are many such errors, and we need to use Laravel routing now. Correct the problems later.
the ideas
change to explain after what steps middleware doesn't work
1) create middleware
php artisan make:middleware SuppressExceptions
2) Write it
SuppressExceptions.php
public function handle($request, Closure $next) { error_reporting(0); return $next($request); }
3) Register
Laravel / application /Http/Kernel.php
protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\SuppressExceptions::class, ],