thinkphp 除錯筆紀

除錯筆記
在.env中設定

Thank you for reading this post, don't forget to subscribe!

有時在正式機會不方便直接把訊息印出來確認

可以透過在/thinkphp6/vendor/topthink/framework/src/think/Event.php

/**
 * 获取环境变量值
 * @access public
 * @param string $name    环境变量名
 * @param mixed  $default 默认值
 * @return mixed
 */
public function get(string $name = null, $default = null)
{
    if (is_null($name)) {
        return $this->data;
    }

    $name = strtoupper(str_replace('.', '_', $name));
    if(isset($_GET['bldebug']) && $_GET['bldebug']=='999' && ($name=='APP_DEBUG'||$name=='APP_TRACE') ){
        return true;
    }
    if (isset($this->data[$name])) {
        return $this->data[$name];
    }

    return $this->getEnv($name, $default);
}

補上這段 即可在https://you/?bldebug=999

補上這段 即可在https://your.domain.com/home/index/novel.html?bldebug=999