Laravel:函数 Illuminate\Support\Manager::createDriver() 的参数太少

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45416202/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:24:44  来源:igfitidea点击:

Laravel: Too few arguments to function Illuminate\Support\Manager::createDriver()

phplaravel

提问by Doddo

I try to test emails with mailtrap and Laravel 5.4. I get this error:

我尝试使用 mailtrap 和 Laravel 5.4 测试电子邮件。我收到此错误:

Type error: Too few arguments to function Illuminate\Support\Manager::createDriver(), 0 passed in C:\Users***\Documents\www\***\backend\vendor\laravel\framework\src\Illuminate\Support\Manager.php on line 88 and exactly 1 expected

类型错误:函数 Illuminate\Support\Manager::createDriver() 的参数太少,0 传入 C:\Users***\Documents\www\***\backend\vendor\laravel\framework\src\Illuminate\ Support\Manager.php 在第 88 行,预期正好是 1

I already tried to config:cache, config:clearetc.

我已经尝试过config:cacheconfig:clear等等。

Here is what php artisan tinkerreturns when I echo env('MAIL_DRIVER')

这是php artisan tinker我回声时返回的内容env('MAIL_DRIVER')

smtp

smtp

Here is my .env file

这是我的 .env 文件

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io 
MAIL_PORT=2525 
MAIL_USERNAME=*********
MAIL_PASSWORD=*********
MAIL_ENCRYPTION=null

And here is my Mail function:

这是我的邮件功能:

Mail::send('email.verify', compact('validation_code'), function($message) {
    $message->to(Input::get('email'), Input::get('username'))
        ->subject('Verify your email address');
});

Any ideas ?

有任何想法吗 ?

Thanks a lot :)

非常感谢 :)

回答by ErcanE

Here is possible solution

这是可能的解决方案

Make sure followings are not empty

确保以下内容不为空

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

回答by Carson Evans

I believe this happens if you do not have the APP_KEY set in a .env file, so run php artisan key:generateif you do not have one.

我相信如果您没有在 .env 文件中设置 APP_KEY 会发生这种情况,所以php artisan key:generate如果您没有,请运行。