Skip to content

Commit 05b1395

Browse files
authored
Merge pull request #11 from quix-labs/laravel-12
Add support for Laravel 12
2 parents 3277454 + d9ea4b0 commit 05b1395

File tree

8 files changed

+128
-97
lines changed

8 files changed

+128
-97
lines changed

.github/workflows/phpstan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup PHP
1919
uses: shivammathur/setup-php@v2
2020
with:
21-
php-version: '8.1'
21+
php-version: '8.4'
2222
coverage: none
2323

2424
- name: Install composer dependencies

.github/workflows/run-tests.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,32 @@ on:
88
- 'phpunit.xml.dist'
99
- 'composer.json'
1010
- 'composer.lock'
11-
1211
jobs:
1312
test:
1413
runs-on: ${{ matrix.os }}
1514
timeout-minutes: 15
1615
strategy:
1716
fail-fast: true
1817
matrix:
19-
os: [ ubuntu-latest ] # [..., windows-latest ]
20-
php: [8.3, 8.2, 8.1]
21-
laravel: [ 10, 11 ]
22-
stability: [ prefer-stable ]
18+
os: [ ubuntu-latest, windows-latest ]
19+
php: [ 8.1, 8.2, 8.3, 8.4 ]
20+
laravel: [ 10, 11, 12 ]
21+
stability: [ prefer-lowest, prefer-stable ]
2322
include:
24-
- laravel: 10
25-
testbench: 8.*
26-
carbon: "^2.72.2|^3.0"
23+
- laravel: 12
24+
testbench: 10.*
2725
- laravel: 11
2826
testbench: 9.*
29-
carbon: "^2.72.2|^3.0"
27+
- laravel: 10
28+
testbench: 8.*
3029
exclude:
3130
- php: 8.1
3231
laravel: 11
32+
- php: 8.1
33+
laravel: 12
34+
# Excluded because testbench is corrupted for versions below
35+
- laravel: 10
36+
stability: prefer-lowest
3337

3438
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
3539

@@ -51,7 +55,7 @@ jobs:
5155
5256
- name: Install dependencies
5357
run: |
54-
composer require "laravel/framework:${{ matrix.laravel }}.*" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
58+
composer require "laravel/framework:${{ matrix.laravel }}.*" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
5559
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
5660
5761
- name: List Installed Dependencies
@@ -63,18 +67,18 @@ jobs:
6367
- name: Upload test results
6468
uses: actions/upload-artifact@v4
6569
with:
66-
name: test-results-${{ matrix.os }}-${{ matrix.php }}-${{ matrix.laravel }}
70+
name: test-results-${{ matrix.os }}-${{ matrix.php }}-${{ matrix.laravel }}-${{ matrix.stability }}
6771
path: build/report.junit.xml
6872
if-no-files-found: ignore
6973
retention-days: 1
7074

71-
# - name: Publish Test Results
72-
# uses: mikepenz/action-junit-report@v5
73-
# if: always()
74-
# with:
75-
# report_paths: 'build/**.junit.xml'
76-
# include_passed: true
77-
# follow_symlink: true
75+
- name: Publish Test Results
76+
uses: mikepenz/action-junit-report@v5
77+
if: always()
78+
with:
79+
report_paths: 'build/**.junit.xml'
80+
include_passed: true
81+
follow_symlink: true
7882

7983
process-test-data:
8084
runs-on: ubuntu-latest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ___
1313
## Requirements
1414

1515
* PHP >= 8.1
16-
* Laravel 10.x|11.x
16+
* Laravel 10.x|11.x|12.x
1717

1818
## Installation
1919

composer.json

Lines changed: 77 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,81 @@
11
{
2-
"name": "quix-labs/laravel-hook-system",
3-
"description": "Add hooks system to Laravel",
4-
"type": "library",
5-
"license": "MIT",
6-
"keywords": [
7-
"laravel",
8-
"hook",
9-
"interceptor"
10-
],
11-
"authors": [
12-
{
13-
"name": "COLANT Alan",
14-
"email": "contact@alancolant.com",
15-
"role": "Developer"
16-
}
17-
],
18-
"require": {
19-
"illuminate/support": "^10.0|^11.0",
20-
"illuminate/contracts": "^10.0|^11.0",
21-
"illuminate/console": "^10.0|^11.0"
22-
},
23-
"require-dev": {
24-
"larastan/larastan": "^2.9",
25-
"laravel/pint": "^1.14",
26-
"nunomaduro/collision": "^8.1.1||^7.10.0",
27-
"orchestra/testbench": "^9.0.0||^8.22.0",
28-
"pestphp/pest": "^2.34",
29-
"pestphp/pest-plugin-arch": "^2.7",
30-
"pestphp/pest-plugin-laravel": "^2.3",
31-
"phpstan/extension-installer": "^1.3",
32-
"phpstan/phpstan-deprecation-rules": "^1.1",
33-
"phpstan/phpstan-phpunit": "^1.3"
34-
},
35-
"autoload": {
36-
"psr-4": {
37-
"QuixLabs\\LaravelHookSystem\\": "src/"
38-
}
39-
},
40-
"autoload-dev": {
41-
"psr-4": {
42-
"QuixLabs\\LaravelHookSystem\\Tests\\": "tests/",
43-
"Workbench\\App\\": "workbench/app/"
44-
}
45-
},
46-
"scripts": {
47-
"post-autoload-dump": "@composer run prepare",
48-
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
49-
"prepare": "@php vendor/bin/testbench package:discover --ansi",
50-
"build": [
51-
"@composer run prepare",
52-
"@php vendor/bin/testbench workbench:build --ansi"
2+
"name": "quix-labs/laravel-hook-system",
3+
"description": "Add hooks system to Laravel",
4+
"type": "library",
5+
"license": "MIT",
6+
"keywords": [
7+
"laravel",
8+
"hook",
9+
"interceptor"
5310
],
54-
"start": [
55-
"Composer\\Config::disableProcessTimeout",
56-
"@composer run build",
57-
"@php vendor/bin/testbench serve"
11+
"authors": [
12+
{
13+
"name": "COLANT Alan",
14+
"email": "contact@alancolant.com",
15+
"role": "Developer"
16+
}
5817
],
59-
"analyse": "vendor/bin/phpstan analyse --memory-limit=1G",
60-
"test": "vendor/bin/pest",
61-
"test-coverage": "XDEBUG_MODE=coverage vendor/bin/pest --coverage",
62-
"format": "vendor/bin/pint"
63-
},
64-
"config": {
65-
"sort-packages": true,
66-
"allow-plugins": {
67-
"pestphp/pest-plugin": true,
68-
"phpstan/extension-installer": true
69-
}
70-
},
71-
"extra": {
72-
"laravel": {
73-
"providers": [
74-
"QuixLabs\\LaravelHookSystem\\Providers\\ServiceProvider"
75-
]
76-
}
77-
},
78-
"minimum-stability": "dev",
79-
"prefer-stable": true
18+
"require": {
19+
"php": "^8.1",
20+
"illuminate/support": "^10.0 || ^11.0 || ^12.0",
21+
"illuminate/contracts": "^10.0 || ^11.0 || ^12.0",
22+
"illuminate/console": "^10.0 || ^11.0 || ^12.0"
23+
},
24+
"require-dev": {
25+
"larastan/larastan": "^2.0.1 || ^3.0",
26+
"laravel/pint": "^1.14",
27+
"nunomaduro/collision": "^8.1.1||^7.10.0",
28+
"orchestra/testbench": "^8.8 || ^9.0 || ^10.0",
29+
"pestphp/pest": "^2.20 || ^3.0 ",
30+
"pestphp/pest-plugin-arch": "^2.0 || ^3.0",
31+
"pestphp/pest-plugin-laravel": "^2.0 || ^3.0",
32+
"phpstan/extension-installer": "^1.3",
33+
"phpstan/phpstan-deprecation-rules": "^1.1 || ^2.0",
34+
"phpstan/phpstan-phpunit": "^1.3 || ^2.0"
35+
},
36+
"autoload": {
37+
"psr-4": {
38+
"QuixLabs\\LaravelHookSystem\\": "src/"
39+
}
40+
},
41+
"autoload-dev": {
42+
"psr-4": {
43+
"QuixLabs\\LaravelHookSystem\\Tests\\": "tests/",
44+
"Workbench\\App\\": "workbench/app/"
45+
}
46+
},
47+
"scripts": {
48+
"post-autoload-dump": "@composer run prepare",
49+
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
50+
"prepare": "@php vendor/bin/testbench package:discover --ansi",
51+
"build": [
52+
"@composer run prepare",
53+
"@php vendor/bin/testbench workbench:build --ansi"
54+
],
55+
"start": [
56+
"Composer\\Config::disableProcessTimeout",
57+
"@composer run build",
58+
"@php vendor/bin/testbench serve"
59+
],
60+
"analyse": "vendor/bin/phpstan analyse --memory-limit=1G",
61+
"test": "vendor/bin/pest",
62+
"test-coverage": "vendor/bin/pest --coverage",
63+
"format": "vendor/bin/pint"
64+
},
65+
"config": {
66+
"sort-packages": true,
67+
"allow-plugins": {
68+
"pestphp/pest-plugin": true,
69+
"phpstan/extension-installer": true
70+
}
71+
},
72+
"extra": {
73+
"laravel": {
74+
"providers": [
75+
"QuixLabs\\LaravelHookSystem\\Providers\\ServiceProvider"
76+
]
77+
}
78+
},
79+
"minimum-stability": "dev",
80+
"prefer-stable": true
8081
}

src/Console/Commands/HooksCacheCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
use Illuminate\Console\Command;
66
use QuixLabs\LaravelHookSystem\Facades\HookManager;
7+
use Symfony\Component\Console\Attribute\AsCommand;
78

9+
#[AsCommand('hooks:cache')]
810
class HooksCacheCommand extends Command
911
{
1012
protected $signature = 'hooks:cache';

src/Console/Commands/HooksClearCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
use Illuminate\Console\Command;
66
use QuixLabs\LaravelHookSystem\Facades\HookManager;
7+
use Symfony\Component\Console\Attribute\AsCommand;
78

9+
#[AsCommand('hooks:clear')]
810
class HooksClearCommand extends Command
911
{
1012
protected $signature = 'hooks:clear';

src/Console/Commands/HooksStatusCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
use QuixLabs\LaravelHookSystem\Hook;
88
use QuixLabs\LaravelHookSystem\Hooks\GetHooksTable;
99
use QuixLabs\LaravelHookSystem\Utils\CommandTable;
10+
use Symfony\Component\Console\Attribute\AsCommand;
1011

12+
#[AsCommand('hooks:status')]
1113
class HooksStatusCommand extends Command
1214
{
1315
protected $signature = 'hooks:status';

src/Providers/ServiceProvider.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider
1616
public function register(): void
1717
{
1818
$this->app->singleton('hooks_manager', function () {
19-
return new HookManager();
19+
return new HookManager;
2020
});
2121
$this->_registerCommands();
2222
$this->_registerHooks();
@@ -26,6 +26,7 @@ public function boot(): void
2626
{
2727
$this->_bootHooksRegistry();
2828
$this->_appendInformationToAboutCommand();
29+
$this->_registerOptimizes();
2930
}
3031

3132
private function _registerHooks(): void
@@ -49,6 +50,7 @@ private function _appendInformationToAboutCommand(): void
4950
if (! $this->app->runningInConsole()) {
5051
return;
5152
}
53+
5254
AboutCommand::add('Cache', fn () => [
5355
'Hooks' => HookManagerFacade::isCached()
5456
? '<fg=green;options=bold>CACHED</>'
@@ -68,4 +70,22 @@ private function _bootHooksRegistry(): void
6870
}
6971
HookRegistry::clear();
7072
}
73+
74+
private function _registerOptimizes(): void
75+
{
76+
if (! $this->app->runningInConsole()) {
77+
return;
78+
}
79+
80+
// @phpstan-ignore-next-line
81+
if (! method_exists($this, 'optimizes')) {
82+
return;
83+
}
84+
85+
$this->optimizes(
86+
optimize: HooksCacheCommand::getDefaultName(),
87+
clear: HooksClearCommand::getDefaultName(),
88+
key: 'hooks'
89+
);
90+
}
7191
}

0 commit comments

Comments
 (0)