bhekor/laravel-brevo 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bhekor/laravel-brevo

最新稳定版本:v1.0.1

Composer 安装命令:

composer require bhekor/laravel-brevo

包简介

Laravel package for Brevo (ex-Sendinblue) API integration

README 文档

README

Complete Brevo (formerly Sendinblue) integration for Laravel, including email support, webhook handling, and optional Vue components.

Latest Version on Packagist Total Downloads GitHub Tests Action Status PHPStan License PHP Version Support Laravel Version Support

Features

  • Seamless integration with Laravel's Mail facade
  • Full support for Markdown Mailables
  • Multiple usage options (default mailer, explicit mailer, facade)
  • Webhook handling
  • Optional Vue components for analytics
  • Comprehensive error handling
  • Modern PHP & Laravel practices (strict typing, PSR-12, PHPDoc)

Installation

composer require bhekor/laravel-brevo

Configuration

Publish the config file:

php artisan vendor:publish --tag=brevo-config

Set your API key and sender details in your .env:

MAIL_MAILER=brevo
BREVO_API_KEY=your_api_key
BREVO_FROM_EMAIL=noreply@example.com
BREVO_FROM_NAME="Your App"

Frontend Integration (Optional)

Install frontend dependencies:

npm install --save-dev @vueuse/core chart.js
php artisan vendor:publish --tag=brevo-assets

In your resources/js/app.js:

import Brevo from '../../public/vendor/laravel-brevo/brevo';
import { createApp } from 'vue';

const app = createApp({});
app.use(Brevo, {
    apiBaseUrl: '/brevo-api'
});

Use components in your Vue template:

<template>
  <BrevoStats />
  <BrevoWebhookLogs />
</template>

Usage

Regular Mailable

Mail::to('user@example.com')->send(new OrderShipped());

Markdown Mailable

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class OrderShipped extends Mailable
{
    use Queueable, SerializesModels;

    public function build()
    {
        return $this->markdown('emails.orders.shipped')
                    ->with([
                        'order' => $this->order,
                    ]);
    }
}

Using the Facade

Brevo::email()->send(new OrderShipped());

Webhooks

  1. Register your webhook endpoint in the Brevo dashboard.
  2. Add the following to your routes/api.php:
Route::brevoWebhooks('/brevo/webhook');

Testing

composer test

Security Vulnerabilities

Please report any security vulnerabilities to security@bhekor.com.

Test Suite

The package includes a robust set of unit and feature tests to ensure reliability.

Directory Structure

tests/
├── Feature/
│   ├── MailTransportTest.php
│   └── WebhookTest.php
└── Unit/
    ├── BrevoClientTest.php
    ├── EventMapperTest.php
    ├── MailTransportTest.php
    ├── TransactionalEmailTest.php
    └── WebhookControllerTest.php

Run all tests with:

composer test

Or use PHPUnit directly:

./vendor/bin/phpunit

Package Structure

bhekor/
└── laravel-brevo/
    ├── config/
    │   └── brevo.php
    ├── resources/
    │   └── js/
    │       ├── components/
    │       │   ├── BrevoStats.vue
    │       │   └── BrevoWebhookLogs.vue
    │       └── brevo.js
    ├── src/
    │   ├── BrevoServiceProvider.php
    │   ├── Contracts/
    │   │   ├── BrevoClientInterface.php
    │   │   └── MailTransportInterface.php
    │   ├── Exceptions/
    │   │   ├── BrevoApiException.php
    │   │   ├── BrevoConfigurationException.php
    │   │   └── BrevoValidationException.php
    │   ├── Facades/
    │   │   └── Brevo.php
    │   ├── Mail/
    │   │   └── BrevoTransport.php
    │   ├── Services/
    │   │   ├── BrevoClient.php
    │   │   └── TransactionalEmail.php
    │   └── Webhooks/
    │       ├── EventMapper.php
    │       ├── WebhookController.php
    │       └── routes.php
    ├── tests/
    │   ├── Feature/
    │   │   ├── MailTransportTest.php
    │   │   └── WebhookTest.php
    │   └── Unit/
    │       ├── BrevoClientTest.php
    │       ├── EventMapperTest.php
    │       ├── MailTransportTest.php
    │       ├── TransactionalEmailTest.php
    │       └── WebhookControllerTest.php
    ├── composer.json
    ├── package.json
    └── README.md

统计信息

  • 总下载量: 451
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-31