gpt4 book ai didi

php - 函数 Illuminate\Support\Manager::createDriver() 的参数太少,在 framework/src/Illuminate/Support/Manager.php 中传递了 0

转载 作者:行者123 更新时间:2023-12-04 08:28:55 28 4
gpt4 key购买 nike

我正在使用 smtp 协议(protocol)使用 mailtrap 发送邮件。它在本地主机中运行良好,但出现错误。

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



.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=name
MAIL_PASSWORD=pass
MAIL_ENCRYPTION=null

邮件.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', 'hello@example.com'),
'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'),
],
],

];

最佳答案

首先:确保您在配置文件夹中设置了 mail.php 和 services.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', 'hello@example.com'),
'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'),
],
],

];

和 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'),
],

];

在你的 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;

运行 php artisan serve终端内
只是为了查看邮件配置的内容。

请注意
我注意到简单的解决方法是使用凭据更新/修改 .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
MAIL_USERNAME=youremail@domain.com
MAIL_PASSWORD=yourpassword
MAIL_ENCRYPTION=tls

MAILGUN_DOMAIN=
MAILGUN_SECRET=

之后,如果您已经在运行您的服务器。杀死它并重新运行它。这应该可以解决您的错误,

原因

由于我无法解释的原因,一些邮件配置参数在我应用上述更改之前没有反射(reflect)。

其次,我后来将 .env 设置更改为原始名称,消除了额外的“_”并更新了 mail.php,并且不得不杀死已经运行的服务器并再次重新运行它,然后才能反射(reflect)并运行良好或正常工作!。

希望这可以帮助

关于php - 函数 Illuminate\Support\Manager::createDriver() 的参数太少,在 framework/src/Illuminate/Support/Manager.php 中传递了 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48297352/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com