php – 完全在Laravel生产中禁用错误??报告?
我想完全禁止生产错误报告,因为我们有一些非常旧的代码,我们仍然需要修复,但现在确实有效(是的我也不喜欢它).我们无法在几天内修复所有内容,因此我们需要像往常一样压制警告和异常.
真正的问题是它已经抛出了一个简单的懒惰错误(因为没有定义var) if(!$var) { // do whatever } 试着
display_errors(false); set_error_handler(null); set_exception_handler(null); 但它仍然显示ErrorException
编辑:代码的工作原理如下 web.php Route::any('/someroute','somecontroller@controllerFunc'); somecontroller.php public controllerFunc() { ob_start(); require '/old_index.php'; $html = ob_get_clean(); return response($html); } 这样我们就可以使用Laravel路由,而无需立即重写旧代码. 我知道我可以很容易地修复这个警告,但是这些错误还有很多,我们现在需要使用Laravel路由.稍后解决问题. 思路 >在$dontReport中使用一些通配符. 编辑解释中间件无法正常工作的步骤 1)创建midddleware php artisan make:middleware SuppressExceptions 2)写下来 SuppressExceptions.php public function handle($request,Closure $next) { error_reporting(0); return $next($request); } 3)注册 laravel /应用/ HTTP / Kernel.php protected $middlewareGroups = [ 'web' => [ AppHttpMiddlewareSuppressExceptions::class,], error_reporting(0); ini_set('display_errors',0); 第二行更改php.ini文件中’display_errors’的值 编辑:添加更多代码,以显示这是如何具体环境… $env = getenv(‘APPLICATION_ENV’); switch ($env) { case 'production': error_reporting(0); $config = include __DIR__ . '/../app/config/config_prod.php'; break; case 'staging': ini_set('display_errors',1); $config = include __DIR__ . '/../app/config/config_staging.php'; break; case 'development': case 'local': default: ini_set('display_errors',1); $config = include __DIR__ . '/../app/config/config_local.php'; break; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |