【发布时间】:2017-11-06 05:29:42
【问题描述】:
我在我的url_prefix 下我安装的包laravel-filemanager 的配置文件中使用了request() 我需要设置目标取决于我的url 所以我使用了request()->segment(2) 一切工作文件除了不能使用工匠命令我收到一个错误显示
[反射异常] 类请求不存在
use Illuminate\Support\Facades\Request 的使用效果不佳
lfm.php
return [
/*
|--------------------------------------------------------------------------
| Routing
|--------------------------------------------------------------------------
*/
// Include to pre-defined routes from package or not. Middlewares
'use_package_routes' => true,
// Middlewares which should be applied to all package routes.
// For laravel 5.1 and before, remove 'web' from the array.
'middlewares' => ['web'],
// The url to this package. Change it if necessary.
'url_prefix' => 'laravel-filemanager/'.request()->segment(2),
因此,为了能够使用工匠命令,我正在做的是暂时删除request()->segment(2),并在使用完后将其带回来非常麻烦。有没有办法解决这个问题?
【问题讨论】:
-
你不能在你的配置文件中使用请求对象——它们是在应用程序启动并且请求对象尚未设置时加载的。
-
@jedrzej.kurylo 谢谢,还有其他方法吗?
-
在服务提供者上设置前缀
-
@jedrzej.kurylo 关于 add first 有两个问题:配置/会话是否在每个请求上运行?并设置这个 'secure' => env('SESSION_SECURE_COOKIE', true), second:这里有没有办法根据 URL 将它设置为 true 或 false
标签: php laravel laravel-5.5