laravel 函数 Illuminate\Support\Manager::createDriver() 的参数太少,0 传入 framework/src/Illuminate/Support/Manager.php
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48297352/
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
Too few arguments to function Illuminate\Support\Manager::createDriver(), 0 passed in framework/src/Illuminate/Support/Manager.php
提问by Osama Malik
I am using smtp protocol to send mails using mailtrap. It is working perfectly in localhost but it is giving error.
我正在使用 smtp 协议使用 mailtrap 发送邮件。它在 localhost 中运行良好,但出现错误。
Symfony\Component\Debug\Exception\FatalThrowableError Type error: Too few arguments to function Illuminate\Support\Manager::createDriver(), 0 passed in public_html/vendor/laravel/framework/src/Illuminate/Support/Manager.php on line 88 and exactly 1 expected
Symfony\Component\Debug\Exception\FatalThrowableError 类型错误:函数 Illuminate\Support\Manager::createDriver() 的参数太少,0 在线传递到 public_html/vendor/laravel/framework/src/Illuminate/Support/Manager.php 88 和正好 1 预期
.env
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=name
MAIL_PASSWORD=pass
MAIL_ENCRYPTION=null
mail.php
邮件.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailtrap.org'),
'port' => env('MAIL_PORT', 2525,
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
回答by lightup
First: Make Sure that you have mail.php and services.php in config folder set
第一:确保您在 config 文件夹集中有 mail.php 和 services.php
with the following respectively:
分别如下:
mail.php
邮件.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailtrap.org'),
'port' => env('MAIL_PORT', 2525,
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
And services.php (note that this includes the mailgun configuration)
和services.php(注意这包括mailgun配置)
<?php
return [
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
'ses' => [
'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'),
'region' => 'us-east-1',
],
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
'stripe' => [
'model' => App\User::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
],
];
ADD THIS ON YOUR boostrap/app/php file
在你的 boostrap/app/php 文件中添加这个
$app->configure('mail'); // this is to configure the mail
$app->configure('services'); // and to configure the services
//$con = env('MAIL_DRIVER');
// dd($con);
dd(config('mail')); // this is to print the mail configuration so you can know what mail configuration are being read.
return $app;
run php artisan servewithin the terminal
just to see the contents of the mail configuration.
php artisan serve在终端内运行只是为了查看邮件配置的内容。
PLEASE NOTEI Noticed that the simple fix is to just UPDATE/MODIFY THE .env file with the credentials(using gmail smtp server as example)
请注意,我注意到简单的修复方法是使用凭据更新/修改 .env 文件(以 gmail smtp 服务器为例)
MAIL_DRIVER_=smtp (instead of MAIL_DRIVER, update it the mail.php)
MAIL_HOST_=smtp.gmail.com (instead of MAIL_HOST)
MAIL_PORT_=587
[email protected]
MAIL_PASSWORD=yourpassword
MAIL_ENCRYPTION=tls
MAILGUN_DOMAIN=
MAILGUN_SECRET=
After that, if you were already running your server. Kill it and rerun it again. This should solve your errors,
之后,如果您已经在运行服务器。杀死它并重新运行它。这应该可以解决您的错误,
REASON
原因
For reasons I couldn't explain, some of the mail config parameter didn't reflect until I applied the change above.
由于我无法解释的原因,在我应用上述更改之前,某些邮件配置参数没有反映出来。
Secondly I later changed the .env settings to the original name eliminating the extra "_" as well as updated the mail.php, and had to kill the already running server and rerun it again before it reflected and ran well or worked!.
其次,我后来将 .env 设置更改为原始名称,消除了额外的“_”并更新了 mail.php,并且不得不杀死已经运行的服务器并再次重新运行它,然后才能反映并运行良好或工作!。
Hope this helps
希望这可以帮助

