简体   繁体   English

如何从 Laravel 的 config/app.php 中获取客户端 ip 地址?

[英]How to get the client ip address from Laravel's config/app.php?

I'm trying to change the debug to true for a certain IP address or addresses for a production Laravel app.我正在尝试将某个 IP 地址或生产 Laravel 应用程序的地址的调试更改为 true。

Tried gett the IP address with $_SERVER['REMOTE_ADDR'] but I get Undefined index: REMOTE_ADDR.尝试使用$_SERVER['REMOTE_ADDR']获取 IP 地址,但我得到未定义的索引:REMOTE_ADDR。

I accomplished setting debug to true from the controller for only the parts that I want to debug using:我完成了从 controller 将debug设置为true ,仅用于我要调试的部分:

if(\Request::ip() == 'my_ip_address'){
    config(['app.debug' => true]);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM