我知道你们中的一些人可能认为这会导致安全问题。
但 ...
我只想更新2
特定的标志,因为有时我想查看报告,有时我不想。如果我有办法更新这些标志——只要我想通过 EMAIL 或 SMS 查看报告,我就可以通过 Apple iPhone Shortcut 连接一个切换该功能的路由。
我试过了
创建了一条路线
Route::get('/env/{flag}/{value}','GeneralController@envUpdate');
叫它
http://localhost/env/MAIL_REPORT/false
这将触发此功能
public function setEnv($key, $val)
{
$path = base_path('.env');
if (file_exists($path)) {
file_put_contents($path, str_replace(
$key . '=' . env($key), $key . '=' . $val, file_get_contents($path)
));
}
}
public function envUpdate($flag,$value)
{
//dd($flag,$value);
$allow_flags = ["MAIL_REPORT", "SMS_REPORT"];
if (in_array($flag, $allow_flags))
{
setEnv((string)$flag, (string)$value);
return env(env((string)$flag));
}
}
我不断收到,true
因为在我的 .env 中似乎没有更新
MAIL_REPORT=true
我想有MAIL_REPORT=false
注意:我已经跑了:sudo chmod 777 .env
如何进行并进一步调试呢?