繁体   English   中英

为什么我在Laravel中遇到此错误:PHP Catchable致命错误?

[英]Why am I getting this error with Laravel: PHP Catchable Fatal Error?

当我尝试运行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

我完全不知道造成它的原因是什么,需要帮助。

提前致谢

好吧,我发现了产生错误的原因。

config/services.php我这样做:

'facebook' => [
    'client_id'     => env('FACEBOOK_APP_ID', null),
    'client_secret' => env('FACEBOOK_APP_SECRET', null),
    'redirect'      => url('auth/facebook'),
]

url('auth/facebook')是导致错误的原因。

正如您所知,问题是由在config中使用url()引起的。 如果您使用asset(),也会发生同样的情况。 当运行artisan命令时,框架无法弄清楚网站URL是什么,因此错误。

我只是想提出一个替代解决方案:

'facebook' => [
  'client_id'     => '***'
  'client_secret' => '***',
  'redirect'      => PHP_SAPI === 'cli' ? false : url('/fb-callback-path'),
]

我不喜欢它,但是在运行命令行脚本时你不太可能需要你的FB重定向,这样你就不必记住在每个environemnt中配置重定向了。

该问题是由在config中使用url()引起的。 我从config / filesystems.php中删除了它,它工作了! 我希望能帮到你!

暂无
暂无

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

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