From 1ac9c62c6b4ea0a21ac38614b2bbd2c143ec5efe Mon Sep 17 00:00:00 2001 From: Al Amin Ahamed Date: Sun, 23 Mar 2025 19:19:21 +0600 Subject: [PATCH 1/5] fix: type error to assign the drie for image manager class --- src/Commands/GenerateFaviconsCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Commands/GenerateFaviconsCommand.php b/src/Commands/GenerateFaviconsCommand.php index 7ec7896..6117ef4 100644 --- a/src/Commands/GenerateFaviconsCommand.php +++ b/src/Commands/GenerateFaviconsCommand.php @@ -5,6 +5,7 @@ namespace ArchTech\SEO\Commands; use Illuminate\Console\Command; +use Intervention\Image\Drivers\Imagick\Driver as ImagickDriver; use Intervention\Image\ImageManager; class GenerateFaviconsCommand extends Command @@ -38,7 +39,7 @@ public function handle(): int } // GD driver doesn't support .ico, that's why we use ImageMagick. - $manager = new ImageManager(['driver' => 'imagick']); + $manager = new ImageManager(ImagickDriver::class); $this->comment('Generating ico...'); From 4b4197d3ade97e826d096dcedc528aff70ed9eb4 Mon Sep 17 00:00:00 2001 From: Al Amin Ahamed Date: Sat, 29 Mar 2025 09:41:06 +0600 Subject: [PATCH 2/5] fix: update package names and handle Intervention Image versioning in favicon generation --- composer.json | 4 +- phpstan.neon | 2 +- src/Commands/GenerateFaviconsCommand.php | 51 ++++++++++++++++-------- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index 4aa74ab..1731a6e 100644 --- a/composer.json +++ b/composer.json @@ -29,10 +29,10 @@ }, "require-dev": { "orchestra/testbench": ">=8.0", - "nunomaduro/larastan": ">=2.4", + "larastan/larastan": ">=2.4", "pestphp/pest": ">=2.0", "pestphp/pest-plugin-laravel": ">=2.0", - "intervention/image": "^2.7" + "intervention/image": "^2.0|^3.0" }, "extra": { "laravel": { diff --git a/phpstan.neon b/phpstan.neon index d8f0cf3..0f34444 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ includes: - - ./vendor/nunomaduro/larastan/extension.neon + - ./vendor/larastan/larastan/extension.neon parameters: paths: diff --git a/src/Commands/GenerateFaviconsCommand.php b/src/Commands/GenerateFaviconsCommand.php index 6117ef4..75e3ab0 100644 --- a/src/Commands/GenerateFaviconsCommand.php +++ b/src/Commands/GenerateFaviconsCommand.php @@ -5,7 +5,6 @@ namespace ArchTech\SEO\Commands; use Illuminate\Console\Command; -use Intervention\Image\Drivers\Imagick\Driver as ImagickDriver; use Intervention\Image\ImageManager; class GenerateFaviconsCommand extends Command @@ -38,22 +37,40 @@ public function handle(): int return self::FAILURE; } - // GD driver doesn't support .ico, that's why we use ImageMagick. - $manager = new ImageManager(ImagickDriver::class); - - $this->comment('Generating ico...'); - - $manager - ->make($path) - ->resize(32, 32) - ->save(public_path('favicon.ico')); - - $this->comment('Generating png...'); - - $manager - ->make($path) - ->resize(32, 32) - ->save(public_path('favicon.png')); + // Check Intervention Image version + $isV3 = interface_exists('\Intervention\Image\Interfaces\DriverInterface'); + + if ($isV3) { + // v3.x implementation + $manager = new ImageManager( + new \Intervention\Image\Drivers\Imagick\Driver() + ); + + $this->comment('Generating ico...'); + $image = $manager->read($path); + $image->resize(32, 32); + $image->save(public_path('favicon.ico')); + + $this->comment('Generating png...'); + $image = $manager->read($path); + $image->resize(32, 32); + $image->save(public_path('favicon.png')); + } else { + // v2.x implementation + $manager = new ImageManager(['driver' => 'imagick']); // @phpstan-ignore argument.type + + $this->comment('Generating ico...'); + $manager // @phpstan-ignore method.notFound + ->make($path) + ->resize(32, 32) + ->save(public_path('favicon.ico')); + + $this->comment('Generating png...'); + $manager // @phpstan-ignore method.notFound + ->make($path) + ->resize(32, 32) + ->save(public_path('favicon.png')); + } $this->info('All favicons have been generated!'); From 6c213a9f6f7668169c1aedc88ec20c6cfa5c2038 Mon Sep 17 00:00:00 2001 From: Al Amin Ahamed Date: Sat, 29 Mar 2025 09:45:42 +0600 Subject: [PATCH 3/5] fix: update intervention/image version constraint in composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1731a6e..3c8ef3b 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "larastan/larastan": ">=2.4", "pestphp/pest": ">=2.0", "pestphp/pest-plugin-laravel": ">=2.0", - "intervention/image": "^2.0|^3.0" + "intervention/image": "^2.7|^3.0" }, "extra": { "laravel": { From 6d61686f684ab30d7cde1ff7b66d538fd420badf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sat, 29 Mar 2025 15:59:07 +0100 Subject: [PATCH 4/5] cleanup, run CI tests with both intervention v2 and v3 --- .github/workflows/ci.yml | 7 +++++-- composer.json | 2 +- src/Commands/GenerateFaviconsCommand.php | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e29f1e1..39d044a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,11 +7,12 @@ on: jobs: pest: - name: Tests (Pest) L${{ matrix.laravel }} + name: Tests (Pest) L${{ matrix.laravel }} I${{ matrix.intervention }} runs-on: ubuntu-latest strategy: matrix: laravel: [10, 11, 12] + intervention: [2, 3] steps: - uses: actions/checkout@v2 @@ -22,7 +23,9 @@ jobs: tools: composer:v2 coverage: none - name: Install composer dependencies - run: composer require "laravel/framework:^${{matrix.laravel}}.0" + run: | + composer require "laravel/framework:^${{matrix.laravel}}.0" + composer require "intervention/image:^${{matrix.intervention}}.0" - name: Run tests run: vendor/bin/pest diff --git a/composer.json b/composer.json index 3c8ef3b..5d9a7d7 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "larastan/larastan": ">=2.4", "pestphp/pest": ">=2.0", "pestphp/pest-plugin-laravel": ">=2.0", - "intervention/image": "^2.7|^3.0" + "intervention/image": "^3.0" }, "extra": { "laravel": { diff --git a/src/Commands/GenerateFaviconsCommand.php b/src/Commands/GenerateFaviconsCommand.php index 75e3ab0..5dfc2f5 100644 --- a/src/Commands/GenerateFaviconsCommand.php +++ b/src/Commands/GenerateFaviconsCommand.php @@ -38,9 +38,9 @@ public function handle(): int } // Check Intervention Image version - $isV3 = interface_exists('\Intervention\Image\Interfaces\DriverInterface'); + $interventionV3 = interface_exists('\Intervention\Image\Interfaces\DriverInterface'); - if ($isV3) { + if ($interventionV3) { // v3.x implementation $manager = new ImageManager( new \Intervention\Image\Drivers\Imagick\Driver() From f1d24db5ffe8351d20e2a56326696621fb3dfda6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sat, 29 Mar 2025 16:02:36 +0100 Subject: [PATCH 5/5] ci: composer require --dev --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39d044a..363616d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,8 +24,8 @@ jobs: coverage: none - name: Install composer dependencies run: | - composer require "laravel/framework:^${{matrix.laravel}}.0" - composer require "intervention/image:^${{matrix.intervention}}.0" + composer require --dev "laravel/framework:^${{matrix.laravel}}.0" + composer require --dev "intervention/image:^${{matrix.intervention}}.0" - name: Run tests run: vendor/bin/pest