Skip to content

Commit 97bc67e

Browse files
authored
Upgrade Laravel (#2)
* switch to github actions * upgrade phpunit * remove testbench dependency * install and apply php-cs-fixer * use anonymous class in SendGridChannelTest * update readme * update composer.json
1 parent 07bb7e8 commit 97bc67e

14 files changed

+182
-109
lines changed

.github/workflows/main.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: run-tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
test:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: true
16+
matrix:
17+
# Disable testing on windows for now...
18+
# os: [ubuntu-latest, windows-latest]
19+
os: [ubuntu-latest]
20+
php: [7.4, 8.0, 8.1]
21+
laravel: [7.*, 8.*, 9.*]
22+
#stability: [prefer-lowest, prefer-stable]
23+
stability: [prefer-stable]
24+
include:
25+
- laravel: 7.*
26+
- laravel: 8.*
27+
- laravel: 9.*
28+
# Laravel 7 has no support for PHP 8.1
29+
exclude:
30+
- laravel: 7.*
31+
php: 8.1
32+
# Older versions of L7 doesn't support PHP 8
33+
- laravel: 7.*
34+
php: 8
35+
stability: prefer-lowest
36+
# Laravel 9 doesn't support < PHP 8
37+
- laravel: 9.*
38+
php: 7.4
39+
40+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
41+
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v2
45+
46+
- name: Setup PHP
47+
uses: shivammathur/setup-php@v2
48+
with:
49+
php-version: ${{ matrix.php }}
50+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
51+
coverage: none
52+
53+
- name: Setup problem matchers
54+
run: |
55+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
56+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
57+
- name: Install dependencies
58+
run: |
59+
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
60+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
61+
- name: Execute tests
62+
run: vendor/bin/phpunit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ composer.phar
44
composer.lock
55
.DS_Store
66
.phpunit.result.cache
7+
.php-cs-fixer.cache

.php-cs-fixer.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->notPath('vendor')
5+
->in([
6+
__DIR__ . '/src',
7+
__DIR__ . '/tests',
8+
])
9+
->name('*.php')
10+
->notName('*.blade.php')
11+
->ignoreDotFiles(true)
12+
->ignoreVCS(true);
13+
14+
$config = new PhpCsFixer\Config();
15+
16+
return $config->setRules([
17+
18+
'@PSR2' => true,
19+
'array_syntax' => ['syntax' => 'short'],
20+
'ordered_imports' => ['sort_algorithm' => 'length'],
21+
'no_unused_imports' => true,
22+
'not_operator_with_successor_space' => true,
23+
'trailing_comma_in_multiline' => true,
24+
'phpdoc_scalar' => true,
25+
'unary_operator_spaces' => true,
26+
'binary_operator_spaces' => true,
27+
'blank_line_before_statement' => [
28+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
29+
],
30+
'phpdoc_single_line_var_spacing' => true,
31+
'phpdoc_var_without_name' => true,
32+
'class_attributes_separation' => [
33+
'elements' => [
34+
'method' => 'one',
35+
],
36+
],
37+
'method_argument_space' => [
38+
'on_multiline' => 'ensure_fully_multiline',
39+
'keep_multiple_spaces_after_comma' => true,
40+
],
41+
'single_trait_insert_per_statement' => true,
42+
])
43+
->setFinder($finder);

.scrutinizer.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.styleci.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes will be documented in this file
44

5+
## 2.0.0 - 2022-04-07
6+
7+
- Added support for Laravel 8 and 9.
8+
9+
## 1.0.1 - 2020-08-11
10+
11+
- stable release for Laravel 5, 6 and 7.
12+
513
## 0.0.4 - 2020-08-11
614

715
- initial release

README.md

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
33
[![Total Downloads](https://img.shields.io/packagist/dt/swiftmade/laravel-sendgrid-notification-channel.svg?style=flat-square)](https://packagist.org/packages/swiftmade/laravel-sendgrid-notification-channel)
44

5-
This package makes it easy to send notifications using [SendGrid](https://sendgrid.com) Dynamic Emails API with Laravel 5.5+, 6.x and 7.x
5+
Allows you to send Laravel notifications using Sendgrid's [Dynamic Transactional Templates](https://docs.sendgrid.com/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates) feature. Supports Laravel 7.x, 8.x and 9.x.
66

7-
## Contents
7+
(For older versions of Laravel, install v1)
88

9-
- [Installation](#installation)
10-
- [Usage](#usage)
11-
- [Changelog](#changelog)
12-
- [Testing](#testing)
13-
- [Security](#security)
14-
- [Contributing](#contributing)
15-
- [Credits](#credits)
16-
- [License](#license)
9+
## Contents
1710

11+
- [Installation](#installation)
12+
- [Usage](#usage)
13+
- [Changelog](#changelog)
14+
- [Testing](#testing)
15+
- [Security](#security)
16+
- [Contributing](#contributing)
17+
- [Credits](#credits)
18+
- [License](#license)
1819

1920
## Installation
2021

@@ -24,19 +25,34 @@ To get started, you need to require this package:
2425
composer require swiftmade/laravel-sendgrid-notification-channel
2526
```
2627

27-
The service provider will be auto-detected by Laravel. So, no need to register it manually.
28+
The service provider will be auto-detected by Laravel. If you've turned auto-discovery off, add the following service provider in your `config/app.php`.
29+
30+
```
31+
NotificationChannels\SendGrid\SendGridServiceProvider::class,
32+
```
2833

29-
Next, make sure you have a valid sendgrid api key at `config/services.php`. You may copy the example configuration below to get started:
34+
Next, make sure you have a valid Sendgrid API key in `config/services.php`. You may copy the example configuration below to get started:
3035

3136
```php
37+
return [
38+
39+
// other services...
40+
41+
// add this...
3242
'sendgrid' => [
3343
'api_key' => env('SENDGRID_API_KEY'),
3444
],
45+
];
3546
```
3647

3748
## Usage
3849

39-
To make use of this package, your notification class should look like this:
50+
To send an email using dynamic templates, you need to:
51+
52+
1. Return `SendGridChannel::class` in the `via()` method. (Not `mail`)
53+
2. Add and implement the `toSendGrid($notifiable){ }` method.
54+
55+
Example:
4056

4157
```php
4258
<?php
@@ -55,7 +71,7 @@ class ExampleNotification extends Notification
5571
// And any other channels you want can go here...
5672
];
5773
}
58-
74+
5975
// ...
6076

6177
public function toSendGrid($notifiable)
@@ -67,7 +83,7 @@ class ExampleNotification extends Notification
6783
* ->from('[email protected]', 'App name')
6884
*/
6985
/**
70-
* optionally set the recipient.
86+
* optionally set the recipient.
7187
* by default it's $notifiable->email:
7288
* ->to('[email protected]', 'Mr. Smith')
7389
*/
@@ -79,18 +95,17 @@ class ExampleNotification extends Notification
7995

8096
```
8197

82-
`toSendGrid` method will receive a `$notifiable` entity and should return a `NotificationChannels\SendGrid\SendGridMessage` instance.
83-
84-
💡 Unless you set them explicitly, **From** address will be `config('mail.from.address')` and the **To** value will be what returns from `$notifiable->routeNotificationFor('mail');`
98+
`toSendGrid` method will receive a `$notifiable` entity and should return a `NotificationChannels\SendGrid\SendGridMessage` instance.
8599

100+
💡 Unless you set it explicitly, the **From** address will be set to `config('mail.from.address')` and the **To** value will be what returns from `$notifiable->routeNotificationFor('mail');`
86101

87102
## Changelog
88103

89104
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
90105

91106
## Testing
92107

93-
``` bash
108+
```bash
94109
$ composer test
95110
```
96111

@@ -104,9 +119,9 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
104119

105120
## Credits
106121

107-
- [swiftmade](https://github.com/swiftmade)
108-
- [cuonggt](https://github.com/cuonggt/sendgrid)
109-
- [All Contributors](../../contributors)
122+
- [swiftmade](https://github.com/swiftmade)
123+
- [cuonggt](https://github.com/cuonggt/sendgrid)
124+
- [All Contributors](../../contributors)
110125

111126
## License
112127

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
],
1414
"require": {
1515
"php": ">=7.2",
16-
"illuminate/notifications": "~5.5 || ~6.0 || ~7.0",
17-
"illuminate/support": "~5.5 || ~6.0 || ~7.0",
18-
"sendgrid/sendgrid": "^7.8"
16+
"illuminate/notifications": "^7.0|^8.0|^9.0",
17+
"illuminate/support": "^7.0|^8.0|^9.0",
18+
"sendgrid/sendgrid": "^7.11"
1919
},
2020
"require-dev": {
21+
"friendsofphp/php-cs-fixer": "^3.8",
2122
"mockery/mockery": "^1.3",
22-
"phpunit/phpunit": "^8.0"
23+
"phpunit/phpunit": "^8.4|^9.0"
2324
},
2425
"autoload": {
2526
"psr-4": {
@@ -45,4 +46,4 @@
4546
]
4647
}
4748
}
48-
}
49+
}

phpunit.xml.dist renamed to phpunit.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,4 @@
1919
<directory suffix=".php">src/</directory>
2020
</whitelist>
2121
</filter>
22-
<logging>
23-
<log type="tap" target="build/report.tap"/>
24-
<log type="junit" target="build/report.junit.xml"/>
25-
<log type="coverage-html" target="build/coverage"/>
26-
<log type="coverage-text" target="build/coverage.txt"/>
27-
<log type="coverage-clover" target="build/logs/clover.xml"/>
28-
</logging>
2922
</phpunit>

0 commit comments

Comments
 (0)