如何在生产中禁用转储

如何在生产中禁用转储

本文介绍了如何在生产中禁用转储 symfony 功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何禁用dump()函数,什么时候在生产环境?如果我在任何地方忘记了转储功能,它就会因 500 错误而崩溃

How to disable dump() function,when its in production environment?If i forget the dump function anywhere It crashes with an 500 error

推荐答案

你应该从你的生产代码中删除 dump()s,它不一定在那里.

You should remove the dump()s from your production code, it doesn't have to be there.

但是,如href="https://stackoverflow.com/users/1146363/cerad">Cerad,因为在签入前忘记删除它们会很烦人,所以您可以定义一个空的 dump()web/app.php开头的函数:

But, as noted by Cerad, since it can be annoying when you forget to remove them before checking in, you can define an empty dump() function at the begining of web/app.php:

<?php

use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;

function dump($object){
    return;
}


$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
//rest of app.php

这篇关于如何在生产中禁用转储 symfony 功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 09:06