mirror of
https://github.com/archtechx/laravel-seo.git
synced 2026-05-06 09:44:03 +00:00
Intervention Image v3 support (#45)
* fix: type error to assign the drie for image manager class * fix: update package names and handle Intervention Image versioning in favicon generation * fix: update intervention/image version constraint in composer.json * cleanup, run CI tests with both intervention v2 and v3 * ci: composer require --dev * phpstan fixes --------- Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
parent
f79d417145
commit
713ecea0d5
4 changed files with 38 additions and 17 deletions
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
|
|
@ -7,11 +7,12 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pest:
|
pest:
|
||||||
name: Tests (Pest) L${{ matrix.laravel }}
|
name: Tests (Pest) L${{ matrix.laravel }} I${{ matrix.intervention }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
laravel: [10, 11, 12, 13]
|
laravel: [10, 11, 12, 13]
|
||||||
|
intervention: [2, 3]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
@ -20,7 +21,9 @@ jobs:
|
||||||
with:
|
with:
|
||||||
php-version: 8.3
|
php-version: 8.3
|
||||||
- name: Install composer dependencies
|
- name: Install composer dependencies
|
||||||
run: composer require "laravel/framework:^${{matrix.laravel}}.0"
|
run: |
|
||||||
|
composer require --dev "laravel/framework:^${{matrix.laravel}}.0"
|
||||||
|
composer require --dev "intervention/image:^${{matrix.intervention}}.0"
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: vendor/bin/pest
|
run: vendor/bin/pest
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,10 @@
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"orchestra/testbench": ">=8.0",
|
"orchestra/testbench": ">=8.0",
|
||||||
"nunomaduro/larastan": ">=2.4",
|
"larastan/larastan": ">=2.4",
|
||||||
"pestphp/pest": ">=2.0",
|
"pestphp/pest": ">=2.0",
|
||||||
"pestphp/pest-plugin-laravel": ">=2.0",
|
"pestphp/pest-plugin-laravel": ">=2.0",
|
||||||
"intervention/image": "^2.7"
|
"intervention/image": "^3.0"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"laravel": {
|
"laravel": {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
includes:
|
includes:
|
||||||
- ./vendor/nunomaduro/larastan/extension.neon
|
- ./vendor/larastan/larastan/extension.neon
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
paths:
|
paths:
|
||||||
|
|
|
||||||
|
|
@ -37,22 +37,40 @@ class GenerateFaviconsCommand extends Command
|
||||||
return self::FAILURE;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GD driver doesn't support .ico, that's why we use ImageMagick.
|
// Check Intervention Image version
|
||||||
$manager = new ImageManager(['driver' => 'imagick']);
|
$interventionV3 = interface_exists('\Intervention\Image\Interfaces\DriverInterface');
|
||||||
|
|
||||||
|
if ($interventionV3) {
|
||||||
|
// v3.x implementation
|
||||||
|
$manager = new ImageManager(
|
||||||
|
new \Intervention\Image\Drivers\Imagick\Driver()
|
||||||
|
);
|
||||||
|
|
||||||
$this->comment('Generating ico...');
|
$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
|
$manager
|
||||||
->make($path)
|
->make($path) // @phpstan-ignore method.notFound
|
||||||
->resize(32, 32)
|
->resize(32, 32)
|
||||||
->save(public_path('favicon.ico'));
|
->save(public_path('favicon.ico'));
|
||||||
|
|
||||||
$this->comment('Generating png...');
|
$this->comment('Generating png...');
|
||||||
|
|
||||||
$manager
|
$manager
|
||||||
->make($path)
|
->make($path) // @phpstan-ignore method.notFound
|
||||||
->resize(32, 32)
|
->resize(32, 32)
|
||||||
->save(public_path('favicon.png'));
|
->save(public_path('favicon.png'));
|
||||||
|
}
|
||||||
|
|
||||||
$this->info('All favicons have been generated!');
|
$this->info('All favicons have been generated!');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue