Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 --dev "laravel/framework:^${{matrix.laravel}}.0"
composer require --dev "intervention/image:^${{matrix.intervention}}.0"
- name: Run tests
run: vendor/bin/pest

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "^3.0"
},
"extra": {
"laravel": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
- ./vendor/nunomaduro/larastan/extension.neon
- ./vendor/larastan/larastan/extension.neon

parameters:
paths:
Expand Down
50 changes: 34 additions & 16 deletions src/Commands/GenerateFaviconsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,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(['driver' => 'imagick']);

$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
$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...');
$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!');

Expand Down
Loading