thinkphpÔõÑù¹Ø±Õtraceµ÷ÊÔģʽ
ΪʲôҪ¹Ø±Õ trace ģʽ£¿
Trace ģʽÊÇ ThinkPHP ×Ô´øµÄµ÷ÊÔģʽ£¬¿ÉÒÔÔÚÒ³Ãæµ×²¿Àû±ãµØÉó²éÄ¿½ñÇëÇóµÄÏà¹ØÐÅÏ¢£¬ÈçÇëÇó²ÎÊý¡¢SQL Óï¾äµÈ£¬¶ÔÎÊÌⶨλºÜÊÇÓÐ×ÊÖú¡£However, in a production environment, we do not want these sensitive information to be leaked and thereby affect the system’s security.¡£±ðµÄ£¬µ÷ÊÔģʽ»¹»á´øÀ´Ò»¶¨µÄÐÔÄÜÏûºÄ£¬Òò´ËÎÒÃÇÓÐÐëÒª½«Æä¹Ø±Õ¡£
ÔõÑù¹Ø±Õ trace ģʽ£¿
ThinkPHP ĬÈÏÊÇ¿ªÆô trace ģʽµÄ£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÉèÖà app_debug ²ÎÊýÀ´¹Ø±Õ trace ģʽ¡£
ÔÚ config Ŀ¼Ï嵀 app.php ÎļþÖУ¬ÎÒÃÇ¿ÉÒÔÕÒµ½ÒÔÏÂÉèÖãº
// ÊÇ·ñ¿ªÆôÓ¦Óõ÷ÊÔģʽ 'app_debug' => env('app_debug', true),
µÇ¼ºó¸´ÖÆ
½« app_debug µÄÖµÉèÖÃΪ false ¼´¿É¹Ø±Õ trace ģʽ£¬´úÂëÈçÏÂËùʾ£º
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
// ÊÇ·ñ¿ªÆôÓ¦Óõ÷ÊÔģʽ 'app_debug' => false,
µÇ¼ºó¸´ÖÆ
³ýÁËͨ¹ýÐÞ¸ÄÉèÖÃÎļþÀ´¹Ø±Õ trace ģʽ֮Í⣬ÎÒÃÇ»¹¿ÉÒÔÔÚÓ¦ÓóÌÐòµÄ¿ØÖÆÆ÷£¨Í¨³£ÊÇ»ù´¡¿ØÖÆÆ÷£©ÖÐÌí¼ÓÒÔÏÂÒªÁ죺
/** * ½á¹¹º¯Êý * * ¹Ø±Õµ÷ÊÔģʽ */ public function __construct() { parent::__construct(); // ¿ª·¢ÇéÐÎÏ£¬²»¹Ø±Õµ÷ÊÔ if (config('app_debug')) { return; } // ¹Ø±Õµ÷ÊÔ config('app_trace', false); config('app_debug', false); }
µÇ¼ºó¸´ÖÆ
Õâ¸öÒªÌå»áÔÚ¿ØÖÆÆ÷³õʼ»¯Ê±±»Å²Óã¬ÈôÊÇ app_debug ÉèÖÃΪ false£¬Ôò»á¹Ø±Õ trace ģʽ¡£
ÒÔÉϾÍÊÇthinkphpÔõÑù¹Ø±Õtraceµ÷ÊÔģʽµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡