我正在创建一个自定义守卫,我需要在其中访问 Request 对象以获取 http header 。我试过 request()
但它在 lumen 中未定义。
如何在 Controller 类之外访问 Request 对象?
最佳答案
我自己从未使用过 Lumen,但您应该能够解决来自服务容器的当前请求:
app('request');
您可能必须传递完整的类名:
app('Illuminate\Http\Request');
关于php - 流明访问 Controller 外部的请求对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46007901/