Mat*_*s17 11 php runtime-error laravel laravel-5
我尝试运行时收到此错误php artisan (anything)
:
PHP Catchable fatal error: Argument 2 passed to
Illuminate\Routing\UrlGenerator::__construct()
must be an instance of Illuminate\Http\Request, null given, called in
/www/laravel5/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php
on line 56 and defined in
/www/laravel5/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php
on line 81
Catchable fatal error: Argument 2 passed to
Illuminate\Routing\UrlGenerator::__construct()
must be an instance of Illuminate\Http\Request, null given, called in
/www/laravel5/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php
on line 56 and defined in
/www/laravel5/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php
on line 81
Run Code Online (Sandbox Code Playgroud)
我完全不知道造成它的原因是什么,需要帮助.
提前致谢
Mat*_*s17 30
好吧,我发现了产生错误的原因.
在config/services.php
我这样做:
'facebook' => [
'client_id' => env('FACEBOOK_APP_ID', null),
'client_secret' => env('FACEBOOK_APP_SECRET', null),
'redirect' => url('auth/facebook'),
]
Run Code Online (Sandbox Code Playgroud)
url('auth/facebook')
是什么导致了错误.
Raf*_* G. 10
正如您所知,问题是由在config中使用url()引起的.如果您使用asset(),也会发生同样的情况.当运行artisan命令时,框架无法弄清楚网站URL是什么,因此错误.
我只是想提出一个替代解决方案:
'facebook' => [
'client_id' => '***'
'client_secret' => '***',
'redirect' => PHP_SAPI === 'cli' ? false : url('/fb-callback-path'),
]
Run Code Online (Sandbox Code Playgroud)
我不喜欢它,但是在运行命令行脚本时你不太可能需要你的FB重定向,这样你就不必记住在每个environemnt中配置重定向了.
归档时间: |
|
查看次数: |
7071 次 |
最近记录: |