Skip to content

Commit

Permalink
Merge pull request #2 from YieldStudio/support-laravel-11
Browse files Browse the repository at this point in the history
feat: Add support for Laravel 11
  • Loading branch information
mckenziearts authored Jul 17, 2024
2 parents e6a6ed8 + f7e9d3a commit 844bf03
Show file tree
Hide file tree
Showing 20 changed files with 133 additions and 81 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/styling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
args: --allow-risky=yes
php-version: 8.1

- name: Install Composer
run: composer install --no-interaction
- name: Run Laravel Pint
run: composer format
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: main

Expand Down
39 changes: 0 additions & 39 deletions .php-cs-fixer.dist.php

This file was deleted.

31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# laravel-brevo-notifier
<p align="center"><img src="./art/logo.svg" alt="Laravel Brevo Notifier Package Logo"></p>

Easily send Brevo transactional email and sms with Laravel notifier.
<p align="center">
<a href="https://github.com/yieldstudio/laravel-brevo-notifier/actions/workflows/tests.yml"><img src="https://img.shields.io/github/actions/workflow/status/yieldstudio/laravel-brevo-notifier/tests.yml?branch=main&style=flat-square" alt="Build Status"></a>
<a href="https://github.com/yieldstudio/laravel-brevo-notifier/releases"><img src="https://img.shields.io/github/release/yieldstudio/laravel-brevo-notifier?style=flat-square" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/yieldstudio/laravel-brevo-notifier"><img src="https://img.shields.io/packagist/dt/yieldstudio/laravel-brevo-notifier?style=flat-square" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/yieldstudio/laravel-brevo-notifier"><img src="https://img.shields.io/packagist/l/yieldstudio/laravel-brevo-notifier" alt="License"></a>
</p>

[![Latest Version](https://img.shields.io/github/release/yieldstudio/laravel-brevo-notifier?style=flat-square)](https://github.com/yieldstudio/laravel-brevo-notifier/releases)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/yieldstudio/laravel-brevo-notifier/tests.yml?branch=main&style=flat-square)](https://github.com/yieldstudio/laravel-brevo-notifier/actions/workflows/tests.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/yieldstudio/laravel-brevo-notifier?style=flat-square)](https://packagist.org/packages/yieldstudio/laravel-brevo-notifier)
Easily send Brevo transactional email and sms with Laravel.

## Installation

composer require yieldstudio/laravel-brevo-notifier
You can install the package via composer:

```bash
composer require yieldstudio/laravel-brevo-notifier
```

## Configure

Expand All @@ -21,9 +28,9 @@ MAIL_FROM_NAME=
BREVO_SMS_SENDER=
```

Make sure that MAIL_FROM_ADDRESS is an authenticated email on Brevo.
Make sure that `MAIL_FROM_ADDRESS` is an authenticated email on Brevo. You can verify by logging in your Brevo account here https://app.brevo.com/senders

BREVO_SMS_SENDER is limited to 11 for alphanumeric characters and 15 for numeric characters.
`BREVO_SMS_SENDER` is limited to 11 for alphanumeric characters and 15 for numeric characters.

You can publish the configuration file with:

Expand All @@ -33,6 +40,8 @@ php artisan vendor:publish --provider="YieldStudio\LaravelBrevoNotifier\BrevoNot

## Usage

Now you can use the channel in your via() method inside the notification:

### Send email

```php
Expand Down Expand Up @@ -61,20 +70,20 @@ class OrderConfirmation extends Notification
}
```

### Send sms
### Send SMS

```php
<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification
use Illuminate\Notifications\Notification;
use YieldStudio\LaravelBrevoNotifier\BrevoSmsChannel;
use YieldStudio\LaravelBrevoNotifier\BrevoSmsMessage;

class OrderConfirmation extends Notification
{
public function via()
public function via(): array
{
return [BrevoSmsChannel::class];
}
Expand Down
8 changes: 8 additions & 0 deletions art/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
],
"require": {
"php": "^8.1|^8.2",
"illuminate/database": "^9|^10",
"illuminate/support": "^9|^10"
"illuminate/database": "^10|^11",
"illuminate/support": "^10|^11"
},
"require-dev": {
"ciareis/bypass": "^1.0",
"friendsofphp/php-cs-fixer": "^3.8",
"laravel/pint": "^1.16",
"orchestra/testbench": "^7.22|^8.1",
"pestphp/pest": "^1.21",
"phpunit/phpunit": "^9.1"
"pestphp/pest": "^2.34",
"phpunit/phpunit": "^10.5"
},
"autoload": {
"psr-4": {
Expand All @@ -50,7 +50,7 @@
}
},
"scripts": {
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
"format": "vendor/bin/pint",
"test": "vendor/bin/pest",
"post-autoload-dump": [
"@php ./vendor/bin/testbench package:discover --ansi"
Expand Down
39 changes: 37 additions & 2 deletions config/brevo.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
<?php

declare(strict_types=1);

return [
/*
|--------------------------------------------------------------------------
| API Token
|--------------------------------------------------------------------------
|
| Your API token from brevo.com.
| see: https://app.brevo.com/settings/keys/api
|
*/

'key' => env('BREVO_KEY'),

/*
|--------------------------------------------------------------------------
| Email Sender
|--------------------------------------------------------------------------
|
| Email and Name used by Brevo when sending email.
| This configuration is used when sending mail.
|
*/

'emailFrom' => [
'email' => env('MAIL_FROM_ADDRESS'),
'name' => env('MAIL_FROM_NAME')
'name' => env('MAIL_FROM_NAME'),
],
'smsFrom' => env('BREVO_SMS_SENDER')

/*
|--------------------------------------------------------------------------
| SMS Sender
|--------------------------------------------------------------------------
|
| Defines the name that will be used as the "from" for all outgoing text messages
| This name is limited to 11 for alphanumeric characters and 15 for numeric characters.
|
*/

'smsFrom' => env('BREVO_SMS_SENDER'),

];
10 changes: 5 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
Expand All @@ -11,12 +11,12 @@
stopOnFailure="false">
<testsuites>
<testsuite name="Laravel Brevo Notifier Test Suite">
<directory>tests</directory>
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src/</directory>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
10 changes: 10 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"preset": "laravel",
"rules": {
"concat_space": {
"spacing": "one"
},
"blank_line_before_statement": true,
"declare_strict_types": true
}
}
Loading

0 comments on commit 844bf03

Please sign in to comment.