From b0711378ad3f869feacb0eb7e083c8c0a28d5bb2 Mon Sep 17 00:00:00 2001 From: Gabi Suciu Date: Mon, 1 Jul 2024 11:54:09 +0300 Subject: [PATCH 01/10] Possible fix for issue #53 --- src/HeloLaravelServiceProvider.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/HeloLaravelServiceProvider.php b/src/HeloLaravelServiceProvider.php index 52565a4..f1ae5ee 100644 --- a/src/HeloLaravelServiceProvider.php +++ b/src/HeloLaravelServiceProvider.php @@ -65,11 +65,11 @@ public function register() protected function bootMailable() { - $instance = app()->make(Mailer::class); + $instance = app()->make(MailManager::class, ['app' => app()]); + $mailerInstance = app()->make(Mailer::class); Mail::swap($instance); - - $this->app->instance(MailerContract::class, $instance); + $this->app->instance(MailerContract::class, $mailerInstance); } private function version($app = null): int From 619e41d841f6ca4c82b16a13fa606a1f06037e32 Mon Sep 17 00:00:00 2001 From: Gabi Suciu Date: Mon, 1 Jul 2024 12:04:16 +0300 Subject: [PATCH 02/10] Update HeloLaravelServiceProvider.php --- src/HeloLaravelServiceProvider.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/HeloLaravelServiceProvider.php b/src/HeloLaravelServiceProvider.php index f1ae5ee..511438e 100644 --- a/src/HeloLaravelServiceProvider.php +++ b/src/HeloLaravelServiceProvider.php @@ -65,11 +65,11 @@ public function register() protected function bootMailable() { - $instance = app()->make(MailManager::class, ['app' => app()]); - $mailerInstance = app()->make(Mailer::class); + $managerInstance = app()->make(MailManager::class, ['app' => app()]); + $instance = app()->make(Mailer::class); - Mail::swap($instance); - $this->app->instance(MailerContract::class, $mailerInstance); + Mail::swap($managerInstance); + $this->app->instance(MailerContract::class, $instance); } private function version($app = null): int From 1c816bc313efbe6411b132150a5ce19f57496bd1 Mon Sep 17 00:00:00 2001 From: Shift Date: Sun, 16 Feb 2025 20:26:26 +0000 Subject: [PATCH 03/10] Bump dependencies for Laravel 12 --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 15c2d68..d0a6ac0 100644 --- a/composer.json +++ b/composer.json @@ -17,13 +17,13 @@ "homepage": "https://github.com/beyondcode/helo-laravel", "require": { "php": "^8.0 || ^8.1 || ^8.2", - "illuminate/console": "^8.0 || ^9.0 || ^10.0 || ^11.0", - "illuminate/mail": "^8.0 || ^9.0 || ^10.0 || ^11.0", - "illuminate/view": "^8.0 || ^9.0 || ^10.0 || ^11.0" + "illuminate/console": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0", + "illuminate/mail": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0", + "illuminate/view": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0" }, "require-dev": { - "orchestra/testbench": "^7.0 || ^8.0 || ^9.0", - "pestphp/pest": "1.x-dev || 2.x-dev" + "orchestra/testbench": "^7.0 || ^8.0 || ^9.0 || ^10.0", + "pestphp/pest": "1.x-dev || 2.x-dev || ^3.7" }, "minimum-stability": "dev", "autoload": { From 853ffa45eed2fa7341bc514a42ab415dea9379f1 Mon Sep 17 00:00:00 2001 From: Shift Date: Sun, 16 Feb 2025 20:26:26 +0000 Subject: [PATCH 04/10] Update GitHub Actions for Laravel 12 --- .github/workflows/test.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 984973c..14777ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,12 +7,13 @@ on: jobs: tests: runs-on: ${{ matrix.os }} + strategy: fail-fast: true matrix: os: [ubuntu-latest] php: ['8.0', 8.1, 8.2, 8.3] - laravel: [9.*, 10.*, 11.*] + laravel: ['9.*', '10.*', '11.*', '12.*'] dependency-version: [prefer-lowest, prefer-stable] exclude: - laravel: 9.* @@ -27,6 +28,10 @@ jobs: php: '8.0' - laravel: 11.* php: 8.1 + - laravel: 12.* + php: '8.0' + - laravel: 12.* + php: 8.1 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} @@ -46,5 +51,6 @@ jobs: run: | composer require "illuminate/console:${{ matrix.laravel }}" "illuminate/mail:${{ matrix.laravel }}" "illuminate/view:${{ matrix.laravel }}" --no-interaction --no-update composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-progress + - name: Execute tests run: vendor/bin/pest From 5c02e2943a08a2f2e0bcbb364ad8ddb0a4547e6b Mon Sep 17 00:00:00 2001 From: Diana Scharf Date: Fri, 25 Jul 2025 11:49:52 +0200 Subject: [PATCH 05/10] Updated dependencies --- .github/workflows/test.yml | 4 +-- composer.json | 10 +++---- phpunit.xml.dist | 56 ++++++++++++++------------------------ phpunit.xml.dist.bak | 37 +++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 42 deletions(-) create mode 100644 phpunit.xml.dist.bak diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 14777ea..29900ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,8 +12,8 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: ['8.0', 8.1, 8.2, 8.3] - laravel: ['9.*', '10.*', '11.*', '12.*'] + php: [8.2, 8.3, 8.4] + laravel: ['10.*', '11.*', '12.*'] dependency-version: [prefer-lowest, prefer-stable] exclude: - laravel: 9.* diff --git a/composer.json b/composer.json index d0a6ac0..5d34c15 100644 --- a/composer.json +++ b/composer.json @@ -16,13 +16,13 @@ ], "homepage": "https://github.com/beyondcode/helo-laravel", "require": { - "php": "^8.0 || ^8.1 || ^8.2", - "illuminate/console": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0", - "illuminate/mail": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0", - "illuminate/view": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0" + "php": "^8.2", + "illuminate/console": "^10.0 || ^11.0 || ^12.0", + "illuminate/mail": "^10.0 || ^11.0 || ^12.0", + "illuminate/view": "^10.0 || ^11.0 || ^12.0" }, "require-dev": { - "orchestra/testbench": "^7.0 || ^8.0 || ^9.0 || ^10.0", + "orchestra/testbench": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0", "pestphp/pest": "1.x-dev || 2.x-dev || ^3.7" }, "minimum-stability": "dev", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 667a775..268eabc 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,37 +1,23 @@ - - - - tests - - - - - - src - - - - - - - - - - - - - - + + + + tests + + + + + src + + + + + + + + + + + + diff --git a/phpunit.xml.dist.bak b/phpunit.xml.dist.bak new file mode 100644 index 0000000..667a775 --- /dev/null +++ b/phpunit.xml.dist.bak @@ -0,0 +1,37 @@ + + + + + tests + + + + + + src + + + + + + + + + + + + + + + From 161f567dc56cf5b3fac57a921c77a464442c6237 Mon Sep 17 00:00:00 2001 From: Diana Scharf Date: Fri, 25 Jul 2025 12:03:28 +0200 Subject: [PATCH 06/10] Removed support for Laravel 7 --- src/CreatesMailers.php | 58 ------------------------------ src/HeloLaravelServiceProvider.php | 8 ----- src/Laravel7Mailer.php | 18 ---------- src/Laravel8Mailer.php | 13 ++++++- tests/HeloTest.php | 7 +--- 5 files changed, 13 insertions(+), 91 deletions(-) delete mode 100644 src/Laravel7Mailer.php diff --git a/src/CreatesMailers.php b/src/CreatesMailers.php index 3fb0aa1..35cc8b9 100644 --- a/src/CreatesMailers.php +++ b/src/CreatesMailers.php @@ -8,64 +8,6 @@ trait CreatesMailers { - protected function createLaravel6Mailer($app) - { - $config = $this->getConfig(); - - // Once we have create the mailer instance, we will set a container instance - // on the mailer. This allows us to resolve mailer classes via containers - // for maximum testability on said classes instead of passing Closures. - $mailer = new Mailer( - $app['view'], - $app['swift.mailer'], - $app['events'] - ); - - if ($app->bound('queue')) { - $mailer->setQueue($app['queue']); - } - - // Next we will set all of the global addresses on this mailer, which allows - // for easy unification of all "from" addresses as well as easy debugging - // of sent messages since they get be sent into a single email address. - foreach (['from', 'reply_to', 'to'] as $type) { - $this->setGlobalAddress($mailer, $config, $type); - } - - return $mailer; - } - - protected function createLaravel7Mailer($app) - { - $defaultDriver = $app['mail.manager']->getDefaultDriver(); - $config = $this->getConfig($defaultDriver); - - // Laravel 7 no longer bindes the swift.mailer: - $swiftMailer = new Swift_Mailer($app['mail.manager']->createTransport($config)); - - // Once we have create the mailer instance, we will set a container instance - // on the mailer. This allows us to resolve mailer classes via containers - // for maximum testability on said classes instead of passing Closures. - $mailer = new Laravel7Mailer( - 'smtp', - $app['view'], - $swiftMailer, - $app['events'] - ); - - if ($app->bound('queue')) { - $mailer->setQueue($app['queue']); - } - - // Next we will set all of the global addresses on this mailer, which allows - // for easy unification of all "from" addresses as well as easy debugging - // of sent messages since they get be sent into a single email address. - foreach (['from', 'reply_to', 'to', 'return_path'] as $type) { - $this->setGlobalAddress($mailer, $config, $type); - } - - return $mailer; - } protected function createLaravel8Mailer($app) { diff --git a/src/HeloLaravelServiceProvider.php b/src/HeloLaravelServiceProvider.php index 52565a4..83954e2 100644 --- a/src/HeloLaravelServiceProvider.php +++ b/src/HeloLaravelServiceProvider.php @@ -47,14 +47,6 @@ public function register() $this->app->singleton(Mailer::class, function ($app) { $version = $this->version($app); - if ($version < 7) { - return $this->createLaravel6Mailer($app); - } - - if ($version < 8) { - return $this->createLaravel7Mailer($app); - } - if ($version < 9) { return $this->createLaravel8Mailer($app); } diff --git a/src/Laravel7Mailer.php b/src/Laravel7Mailer.php deleted file mode 100644 index 2e80397..0000000 --- a/src/Laravel7Mailer.php +++ /dev/null @@ -1,18 +0,0 @@ -currentMailer = $name; - - return $this; - } -} diff --git a/src/Laravel8Mailer.php b/src/Laravel8Mailer.php index c1bdc29..5fb3aa3 100644 --- a/src/Laravel8Mailer.php +++ b/src/Laravel8Mailer.php @@ -5,8 +5,19 @@ use Illuminate\Contracts\Mail\Factory as MailFactory; use Illuminate\Contracts\Mail\Mailer as MailerContract; -class Laravel8Mailer extends Laravel7Mailer implements MailerContract, MailFactory +class Laravel8Mailer extends Mailer implements MailerContract, MailFactory { + public $currentMailer = null; + protected $app; + protected $mailers = []; + + public function mailer($name = null) + { + $this->currentMailer = $name; + + return $this; + } + /** * Set laravel application. * diff --git a/tests/HeloTest.php b/tests/HeloTest.php index 2099cac..db9d2fd 100644 --- a/tests/HeloTest.php +++ b/tests/HeloTest.php @@ -2,7 +2,6 @@ namespace BeyondCode\HeloLaravel\Tests; -use BeyondCode\HeloLaravel\Laravel7Mailer; use BeyondCode\HeloLaravel\Mailer; use BeyondCode\HeloLaravel\TestMail; use BeyondCode\HeloLaravel\TestMailCommand; @@ -29,9 +28,5 @@ test('the correct mailer is binded', function () { $mailer = app(Mailer::class); - if (version_compare(app()->version(), '7.0.0', '<')) { - $this->assertTrue($mailer instanceof Mailer); - } else { - $this->assertTrue($mailer instanceof Laravel7Mailer); - } + $this->assertTrue($mailer instanceof Mailer); }); From d3566f70c8718caaffe1c92e0f76153b9ff5bfe7 Mon Sep 17 00:00:00 2001 From: Di Date: Fri, 25 Jul 2025 12:03:44 +0200 Subject: [PATCH 07/10] Apply fixes from StyleCI (#57) --- src/CreatesMailers.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CreatesMailers.php b/src/CreatesMailers.php index 35cc8b9..5ede46a 100644 --- a/src/CreatesMailers.php +++ b/src/CreatesMailers.php @@ -8,7 +8,6 @@ trait CreatesMailers { - protected function createLaravel8Mailer($app) { $defaultDriver = $app['mail.manager']->getDefaultDriver(); From 46c5ce51192c10c13cb91861e304d616f40890fd Mon Sep 17 00:00:00 2001 From: Diana Scharf Date: Fri, 25 Jul 2025 13:44:02 +0200 Subject: [PATCH 08/10] Remove support for Laravel 8 and 9, consolidate to GeneralLaravelMailer --- src/CreatesMailers.php | 49 ++----------------- ...el8Mailer.php => GeneralLaravelMailer.php} | 2 +- src/HeloLaravelServiceProvider.php | 8 +-- src/Laravel9Mailer.php | 10 ---- 4 files changed, 7 insertions(+), 62 deletions(-) rename src/{Laravel8Mailer.php => GeneralLaravelMailer.php} (90%) delete mode 100644 src/Laravel9Mailer.php diff --git a/src/CreatesMailers.php b/src/CreatesMailers.php index 5ede46a..b943b6c 100644 --- a/src/CreatesMailers.php +++ b/src/CreatesMailers.php @@ -4,57 +4,22 @@ use Illuminate\Support\Arr; use Illuminate\Support\Str; -use Swift_Mailer; trait CreatesMailers { - protected function createLaravel8Mailer($app) - { - $defaultDriver = $app['mail.manager']->getDefaultDriver(); - $config = $this->getConfig($defaultDriver); - - $swiftMailer = new Swift_Mailer($app['mail.manager']->createTransport($config)); - - // Once we have create the mailer instance, we will set a container instance - // on the mailer. This allows us to resolve mailer classes via containers - // for maximum testability on said classes instead of passing Closures. - $mailer = new Laravel8Mailer( - 'smtp', - $app['view'], - $swiftMailer, - $app['events'] - ); - - if ($app->bound('queue')) { - $mailer->setQueue($app['queue']); - } - - // Next we will set all of the global addresses on this mailer, which allows - // for easy unification of all "from" addresses as well as easy debugging - // of sent messages since they get be sent into a single email address. - foreach (['from', 'reply_to', 'to', 'return_path'] as $type) { - $this->setGlobalAddress($mailer, $config, $type); - } - return $mailer; - } - - protected function createLaravel9Mailer($app) + protected function createGeneralLaravelMailer($app) { $defaultDriver = $app['mail.manager']->getDefaultDriver(); $config = $this->getConfig($defaultDriver); - // We get Symfony Transport from Laravel 9 mailer - if (version_compare(app()->version(), '10.0.0', '<')) { - $symfonyTransport = $app['mail.manager']->getSymfonyTransport(); - } else { - $symfonyTransport = $app['mailer']->getSymfonyTransport(); - } + // We get Symfony Transport from Laravel 10+ mailer + $symfonyTransport = $app['mailer']->getSymfonyTransport(); // Once we have create the mailer instance, we will set a container instance // on the mailer. This allows us to resolve mailer classes via containers // for maximum testability on said classes instead of passing Closures. - $mailer = new Laravel9Mailer( + $mailer = new GeneralLaravelMailer( 'smtp', $app['view'], $symfonyTransport, @@ -93,11 +58,7 @@ protected function getConfig($name = 'smtp') */ protected function setGlobalAddress($mailer, array $config, $type) { - if (version_compare(app()->version(), '7.0.0', '<')) { - $address = Arr::get($config, $type); - } else { - $address = Arr::get($config, $type, $this->app['config']['mail.'.$type]); - } + $address = Arr::get($config, $type, $this->app['config']['mail.'.$type]); if (is_array($address) && isset($address['address'])) { $mailer->{'always'.Str::studly($type)}($address['address'], $address['name']); diff --git a/src/Laravel8Mailer.php b/src/GeneralLaravelMailer.php similarity index 90% rename from src/Laravel8Mailer.php rename to src/GeneralLaravelMailer.php index 5fb3aa3..f7076b0 100644 --- a/src/Laravel8Mailer.php +++ b/src/GeneralLaravelMailer.php @@ -5,7 +5,7 @@ use Illuminate\Contracts\Mail\Factory as MailFactory; use Illuminate\Contracts\Mail\Mailer as MailerContract; -class Laravel8Mailer extends Mailer implements MailerContract, MailFactory +class GeneralLaravelMailer extends Mailer implements MailerContract, MailFactory { public $currentMailer = null; protected $app; diff --git a/src/HeloLaravelServiceProvider.php b/src/HeloLaravelServiceProvider.php index 83954e2..c436d0e 100644 --- a/src/HeloLaravelServiceProvider.php +++ b/src/HeloLaravelServiceProvider.php @@ -45,13 +45,7 @@ public function register() $this->mergeConfigFrom(__DIR__.'/../config/helo.php', 'helo'); $this->app->singleton(Mailer::class, function ($app) { - $version = $this->version($app); - - if ($version < 9) { - return $this->createLaravel8Mailer($app); - } - - return $this->createLaravel9Mailer($app); + return $this->createGeneralLaravelMailer($app); }); } diff --git a/src/Laravel9Mailer.php b/src/Laravel9Mailer.php deleted file mode 100644 index a36093c..0000000 --- a/src/Laravel9Mailer.php +++ /dev/null @@ -1,10 +0,0 @@ - Date: Fri, 25 Jul 2025 13:44:16 +0200 Subject: [PATCH 09/10] Apply fixes from StyleCI (#59) --- src/CreatesMailers.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CreatesMailers.php b/src/CreatesMailers.php index b943b6c..1b40afb 100644 --- a/src/CreatesMailers.php +++ b/src/CreatesMailers.php @@ -7,7 +7,6 @@ trait CreatesMailers { - protected function createGeneralLaravelMailer($app) { $defaultDriver = $app['mail.manager']->getDefaultDriver(); From 13cd92857afb5865da455b9e52928c78c1183ad4 Mon Sep 17 00:00:00 2001 From: Diana Scharf Date: Fri, 25 Jul 2025 14:02:10 +0200 Subject: [PATCH 10/10] Update MailManager to use createGeneralLaravelMailer method --- src/MailManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MailManager.php b/src/MailManager.php index 81c573c..0854360 100644 --- a/src/MailManager.php +++ b/src/MailManager.php @@ -12,7 +12,7 @@ class MailManager extends LaravelMailManager implements FactoryContract public function mailer($name = null) { if (!$name) { - return $this->createLaravel9Mailer($this->app); + return $this->createGeneralLaravelMailer($this->app); } return $this->mailers[$name] = $this->get($name);