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

让人想犯罪 __ 提交于 2019-12-05 00:45:33

Well I discovered what generated the error.

In config/services.php I was doing this:

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

url('auth/facebook') is what caused the error.

As you figured out, the problem is caused by using url() in config. The same would happen if you used asset(). When running artisan commands, the framework can't figure out what the website url is, hence the error.

I just want to propose an alternative solution:

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

I don't love it but it's very unlikely you're ever going to need your FB redirects when running command line scripts and this way you don't have to remember about configuring the redirect in each environemnt.

The problem is caused by using url() in config. i removed it from config/filesystems.php and it worked! i hope help you!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!