Skip to content

Commit a17c7bc

Browse files
authored
Merge pull request #37 from railsware/feature/change-symfony-laravel-integration
Change Symfony&Laravel integration naming [BC BREAK for Symfony&Laravel]
2 parents 1dbed2b + 95a6a38 commit a17c7bc

15 files changed

+287
-101
lines changed

.github/workflows/ci-psalm.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Psalm Analyze
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches:
8+
- 'release/**'
9+
- 'feature/**'
10+
- 'main'
11+
12+
jobs:
13+
psalm-analyze:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: [ ubuntu-latest ]
18+
php-versions: [ '8.0','8.1','8.2','8.3','8.4' ]
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
24+
- name: Setup PHP
25+
id: setup-php
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php-versions }}
29+
extensions: mbstring, intl, curl
30+
31+
- name: Print PHP version
32+
run: echo ${{ steps.setup-php.outputs.php-version }}
33+
34+
- name: Get composer cache directory
35+
id: composer-cache
36+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
37+
38+
- name: Cache dependencies
39+
uses: actions/cache@v3
40+
with:
41+
path: ${{ steps.composer-cache.outputs.dir }}
42+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
43+
restore-keys: ${{ runner.os }}-composer
44+
45+
- name: Install Composer dependencies
46+
run: composer install --prefer-dist --no-progress
47+
48+
- name: Run Psalm analyze
49+
run: vendor/bin/psalm

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [3.0.0] - 2025-05-15
2+
3+
- [BC BREAK] Change Symfony&Laravel integration naming from `mailtrap+api` to `mailtrap+sdk` ([reason](https://symfony.com/packages/MailtrapMailer))
4+
- Rollback Psalm library because now they support PHP 8.4
5+
16
## [2.1.0] - 2025-01-28
27

38
- Use psr/http-factory instead of php-http/message-factory

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Official Mailtrap PHP client
22
===============
33
![GitHub Actions](https://github.com/railsware/mailtrap-php/actions/workflows/ci-phpunit.yml/badge.svg)
4+
![GitHub Actions](https://github.com/railsware/mailtrap-php/actions/workflows/ci-psalm.yaml/badge.svg)
45

56
[![PHP version support](https://img.shields.io/packagist/dependency-v/railsware/mailtrap-php/php?style=flat)](https://packagist.org/packages/railsware/mailtrap-php)
67
[![Latest Version on Packagist](https://img.shields.io/packagist/v/railsware/mailtrap-php.svg?style=flat)](https://packagist.org/packages/railsware/mailtrap-php)

UPGRADE-3.0.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
UPGRADE FROM 2.x to 3.0
2+
=======================
3+
4+
Version 3.0 introduces **breaking changes** for `Laravel` and `Symfony` frameworks.
5+
This guide helps you upgrade your application accordingly.
6+
7+
8+
### Laravel Integration
9+
10+
1. Change mailtrap transport inside your `config/mail.php` file.
11+
12+
__Before__:
13+
```php
14+
<?php
15+
16+
return [
17+
/*
18+
|--------------------------------------------------------------------------
19+
| Mailer Configurations
20+
|--------------------------------------------------------------------------
21+
*/
22+
'mailers' => [
23+
24+
// start mailtrap transport
25+
'mailtrap' => [
26+
'transport' => 'mailtrap'
27+
],
28+
// end mailtrap transport
29+
30+
]
31+
];
32+
```
33+
__After__:
34+
```php
35+
<?php
36+
37+
return [
38+
/*
39+
|--------------------------------------------------------------------------
40+
| Mailer Configurations
41+
|--------------------------------------------------------------------------
42+
*/
43+
'mailers' => [
44+
45+
// start mailtrap transport
46+
'mailtrap-sdk' => [
47+
'transport' => 'mailtrap-sdk'
48+
],
49+
// end mailtrap transport
50+
51+
]
52+
];
53+
```
54+
55+
2. Set `mailtrap-sdk` transport as a default instead `mailtrap` inside your `.env` file.
56+
57+
```bash
58+
MAIL_MAILER="mailtrap-sdk"
59+
```
60+
61+
3. Rename mailtrap config file and variables
62+
63+
__Before__:
64+
```php
65+
# /config/mailtrap.php
66+
67+
<?php
68+
69+
return [
70+
'mailtrap' => [
71+
'host' => env('MAILTRAP_HOST', 'send.api.mailtrap.io'),
72+
'apiKey' => env('MAILTRAP_API_KEY'),
73+
'inboxId' => env('MAILTRAP_INBOX_ID'),
74+
],
75+
];
76+
```
77+
__After__:
78+
```php
79+
# /config/mailtrap-sdk.php
80+
81+
<?php
82+
83+
return [
84+
'mailtrap-sdk' => [
85+
'host' => env('MAILTRAP_HOST', 'send.api.mailtrap.io'),
86+
'apiKey' => env('MAILTRAP_API_KEY'),
87+
'inboxId' => env('MAILTRAP_INBOX_ID'),
88+
],
89+
];
90+
```
91+
92+
### Symfony Integration
93+
1. Change configuration inside your `config/services.yaml` file
94+
95+
__Before__:
96+
```yaml
97+
...
98+
# add more service definitions when explicit configuration is needed
99+
# please note that last definitions always *replace* previous ones
100+
101+
Mailtrap\Bridge\Transport\MailtrapTransportFactory:
102+
tags:
103+
- { name: 'mailer.transport_factory' }
104+
```
105+
__After__:
106+
```yaml
107+
...
108+
# add more service definitions when explicit configuration is needed
109+
# please note that last definitions always *replace* previous ones
110+
111+
Mailtrap\Bridge\Transport\MailtrapSdkTransportFactory:
112+
tags:
113+
- { name: 'mailer.transport_factory' }
114+
```
115+
116+
2. Change MAILER_DSN variable inside your `.env`
117+
118+
__Before__:
119+
```bash
120+
MAILER_DSN=mailtrap://YOUR_API_KEY_HERE@default
121+
# or
122+
MAILER_DSN=mailtrap+api://YOUR_API_KEY_HERE@send.api.mailtrap.io
123+
```
124+
__After__:
125+
```bash
126+
MAILER_DSN=mailtrap+sdk://YOUR_API_KEY_HERE@default
127+
# or
128+
MAILER_DSN=mailtrap+sdk://YOUR_API_KEY_HERE@send.api.mailtrap.io
129+
```

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"symfony/http-client": "^6.0|^7.0",
2222
"symfony/mailer": "^6.0|^7.0",
2323
"phpunit/phpunit": "^9",
24-
"nyholm/psr7": "^1.5"
24+
"nyholm/psr7": "^1.5",
25+
"vimeo/psalm": "^5.0|^6.0"
2526
},
2627
"suggest": {
2728
"nyholm/psr7": "PSR-7 message implementation",
@@ -43,7 +44,7 @@
4344
"extra": {
4445
"laravel": {
4546
"providers": [
46-
"Mailtrap\\Bridge\\Laravel\\MailtrapApiProvider"
47+
"Mailtrap\\Bridge\\Laravel\\MailtrapSdkProvider"
4748
]
4849
}
4950
},

psalm.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="7"
4+
resolveFromConfigFile="true"
5+
findUnusedBaselineEntry="false"
6+
findUnusedCode="false"
7+
allowStringToStandInForClass="true"
8+
ensureOverrideAttribute="false"
9+
cacheDirectory=".psalm-cache"
10+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
11+
xmlns="https://getpsalm.org/schema/config"
12+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
13+
>
14+
<projectFiles>
15+
<directory name="src" />
16+
<ignoreFiles>
17+
<directory name="vendor" />
18+
<directory name="src/Bridge" />
19+
</ignoreFiles>
20+
</projectFiles>
21+
</psalm>

src/Bridge/Laravel/MailtrapApiProvider.php renamed to src/Bridge/Laravel/MailtrapSdkProvider.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66

77
use Illuminate\Support\Facades\Mail;
88
use Illuminate\Support\ServiceProvider;
9-
use Mailtrap\Bridge\Transport\MailtrapTransportFactory;
9+
use Mailtrap\Bridge\Transport\MailtrapSdkTransportFactory;
1010
use Symfony\Component\Mailer\Transport\Dsn;
1111

1212
/**
13-
* Class MailtrapApiProvider
13+
* Class MailtrapSdkProvider
1414
*/
15-
class MailtrapApiProvider extends ServiceProvider
15+
class MailtrapSdkProvider extends ServiceProvider
1616
{
1717
/**
1818
* Register services.
1919
*/
2020
public function register(): void
2121
{
22-
$this->mergeConfigFrom(__DIR__ . '/config/mailtrap.php', 'services');
22+
$this->mergeConfigFrom(__DIR__ . '/config/mailtrap-sdk.php', 'services');
2323
}
2424

2525
/**
@@ -29,15 +29,15 @@ public function boot(): void
2929
{
3030
// https://laravel.com/docs/9.x/upgrade#symfony-mailer
3131
if ((int) $this->app->version() >= 9) {
32-
Mail::extend('mailtrap', function () {
33-
return (new MailTrapTransportFactory)->create(
32+
Mail::extend('mailtrap-sdk', function () {
33+
return (new MailtrapSdkTransportFactory)->create(
3434
new Dsn(
35-
'mailtrap+api',
36-
config('services.mailtrap.host'),
37-
config('services.mailtrap.apiKey'),
35+
'mailtrap+sdk',
36+
config('services.mailtrap-sdk.host'),
37+
config('services.mailtrap-sdk.apiKey'),
3838
null,
3939
null,
40-
config('services.mailtrap', [])
40+
config('services.mailtrap-sdk', [])
4141
)
4242
);
4343
});

src/Bridge/Laravel/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
Mailtrap bridge for Laravel framework [API]
1+
Mailtrap bridge for Laravel framework [SDK]
22
===============
33

4-
Provides mailtrap.io integration for Laravel framework.
4+
Provides full mailtrap.io integration for Laravel framework.
55

66
## Installation
77
If you just want to get started quickly, you should run one of the following command (depends on which HTTP client you want to use):
88
```bash
99
# With symfony http client (recommend)
10-
composer require railsware/mailtrap-php symfony/http-client nyholm/psr7
10+
composer require railsware/mailtrap-php symfony/http-client nyholm/psr7 symfony/mailer
1111

1212
# Or with guzzle http client
13-
composer require railsware/mailtrap-php guzzlehttp/guzzle php-http/guzzle7-adapter
13+
composer require railsware/mailtrap-php guzzlehttp/guzzle php-http/guzzle7-adapter symfony/mailer
1414
```
1515

1616
## Usage
@@ -28,22 +28,22 @@ return [
2828
'mailers' => [
2929

3030
// start mailtrap transport
31-
'mailtrap' => [
32-
'transport' => 'mailtrap'
31+
'mailtrap-sdk' => [
32+
'transport' => 'mailtrap-sdk'
3333
],
3434
// end mailtrap transport
3535

3636
]
37-
]
37+
];
3838
```
3939

40-
Set `mailtrap` transport as a default Laravel mailer and change default mailtrap config variables inside your `.env` file.
40+
Set `mailtrap-sdk` transport as a default Laravel mailer and change default mailtrap config variables inside your `.env` file.
4141

4242

4343
### Sending
4444
You need to set the API key to the `MAILTRAP_API_KEY` variable.
4545
```bash
46-
MAIL_MAILER="mailtrap"
46+
MAIL_MAILER="mailtrap-sdk"
4747

4848
MAILTRAP_HOST="send.api.mailtrap.io"
4949
MAILTRAP_API_KEY="YOUR_API_KEY_HERE"
@@ -53,7 +53,7 @@ You need to set the API key to the `MAILTRAP_API_KEY` variable.
5353

5454
More info about bulk sending -> https://help.mailtrap.io/article/113-sending-streams
5555
```bash
56-
MAIL_MAILER="mailtrap"
56+
MAIL_MAILER="mailtrap-sdk"
5757

5858
MAILTRAP_HOST="bulk.api.mailtrap.io"
5959
MAILTRAP_API_KEY="YOUR_API_KEY_HERE"
@@ -63,7 +63,7 @@ You need to set the API key to the `MAILTRAP_API_KEY` variable and set your inbo
6363

6464
More info sandbox -> https://help.mailtrap.io/article/109-getting-started-with-mailtrap-email-testing
6565
```bash
66-
MAIL_MAILER="mailtrap"
66+
MAIL_MAILER="mailtrap-sdk"
6767

6868
MAILTRAP_HOST="sandbox.api.mailtrap.io"
6969
MAILTRAP_API_KEY="YOUR_API_KEY_HERE"
@@ -217,8 +217,8 @@ use Illuminate\Support\Facades\Mail;
217217
Artisan::command('send-welcome-mail', function () {
218218
Mail::to('testreceiver@gmail.com')->send(new WelcomeMail("Jon"));
219219

220-
// Also, you can use specific mailer if your default mailer is not "mailtrap" but you want to use it for welcome mails
221-
// Mail::mailer('mailtrap')->to('testreceiver@gmail.com')->send(new WelcomeMail("Jon"));
220+
// Also, you can use specific mailer if your default mailer is not "mailtrap-sdk" but you want to use it for welcome mails
221+
// Mail::mailer('mailtrap-sdk')->to('testreceiver@gmail.com')->send(new WelcomeMail("Jon"));
222222
})->purpose('Send welcome mail');
223223
```
224224

src/Bridge/Laravel/config/mailtrap.php renamed to src/Bridge/Laravel/config/mailtrap-sdk.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
return [
4-
'mailtrap' => [
4+
'mailtrap-sdk' => [
55
'host' => env('MAILTRAP_HOST', 'send.api.mailtrap.io'),
66
'apiKey' => env('MAILTRAP_API_KEY'),
77
'inboxId' => env('MAILTRAP_INBOX_ID'),

0 commit comments

Comments
 (0)