I would like to disable error reporting entirely on production, because we have some very old code we still need to fix but for now does work (yes I don't like it either). We cannot fix everything in a few days, so we need to just supress the warnings and exceptions like we always did.
The real problem is that it already throws an exception on a simple lazy bug like (because var is not defined)
if(!$var) {
// do whatever
}
tried
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: The 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);
}
This way we use Laravel routing without having to rewrite the old code immediately.
I know I can fix this warning very easy, but there are many, many more of these errors and we need to use Laravel routing now. Fix the problems later.
ideas
- Use some wildcard in
$dontReport
. - Use a
@
suppression at the right place - Can it be http://php.net/manual/en/scream.examples-simple.php
edit to explain after which steps middleware didn't work
1) create midddleware
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/app/Http/Kernel.php
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\SuppressExceptions::class,
],