bastinald / laravel-exception-emailer
Laravel异常信息及堆栈跟踪邮件发送器。
1.0.4
2021-08-02 14:16 UTC
Requires
- laravel/framework: ^8.0
README
此包将在您的Laravel应用程序中发生任何异常时发送电子邮件。电子邮件包含异常信息和完整的堆栈跟踪。您可以指定发送到的电子邮件地址以及应发送电子邮件的环境。
文档
安装
需要此包
composer require bastinald/laravel-exception-emailer
配置您的.env MAIL设置,例如
MAIL_MAILER=smtp MAIL_HOST=localhost MAIL_PORT=1025 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null MAIL_FROM_ADDRESS=info@laravel.test MAIL_FROM_NAME="${APP_NAME}"
在Handler::register方法中调度EmailException作业
namespace App\Exceptions; use Bastinald\LaravelExceptionEmailer\Jobs\EmailException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Throwable; class Handler extends ExceptionHandler { public function register() { $this->reportable(function (Throwable $e) { EmailException::dispatch($e->getMessage(), $this->renderExceptionContent($e)); }); } }
发布配置文件
php artisan vendor:publish --tag=laravel-exception-emailer:config
在发布的配置文件中设置电子邮件和环境
'emails' => 'admin@example.com', 'environments' => 'production',
发布配置
通过发布配置文件自定义包配置
php artisan vendor:publish --tag=laravel-exception-emailer:config
现在您可以轻松更改电子邮件地址和异常环境等设置。