Skip to content

Commit

Permalink
PHP 8.1 as minimal version.
Browse files Browse the repository at this point in the history
Use PHP 8.2 as default with github workflow and scrutinizer.
  • Loading branch information
jasny committed Aug 28, 2024
1 parent 92220ff commit 87545bd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
25 changes: 14 additions & 11 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ jobs:
fail-fast: false
matrix:
include:
- desc: "Lowest versions"
php: 7.4
- php: 8.1
composer: '--prefer-lowest'
- php: 7.4
coverage: '--coverage-clover /tmp/clover.xml'
- php: 8.0
desc: "Lowest versions"
- php: 8.1
- php: 8.2
coverage: '--coverage-clover /tmp/clover.xml'
- php: 8.3
name: PHP ${{ matrix.php }} ${{ matrix.desc }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -35,13 +37,14 @@ jobs:
run: composer validate

- name: Install dependencies
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer }}
run: composer update --prefer-dist --no-progress ${{ matrix.composer }}

- name: Run PHPUnit
run: vendor/bin/phpunit ${{ matrix.coverage }}

- name: Upload coverage to Scrutinizer
- name: Upload Scrutinizer coverage
uses: sudo-bot/action-scrutinizer@latest
if: ${{ matrix.coverage }}
run: >
wget https://scrutinizer-ci.com/ocular.phar -O "/tmp/ocular.phar" &&
php "/tmp/ocular.phar" code-coverage:upload --format=php-clover /tmp/clover.xml
with:
cli-args: "--format=php-clover build/logs/clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}"

2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build:
nodes:
analysis:
environment:
php: 7.4
php: 8.2
postgresql: false
redis: false
mongodb: false
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Installation

composer require jasny/switch-route

Requires PHP 7.2+
Requires PHP 8.2+

Usage
---
Expand Down Expand Up @@ -202,8 +202,18 @@ $request = new ServerRequest($_SERVER, $_COOKIE, $_QUERY, $_POST, $_FILES);
$response = $relay->handle($request);
```

_You typically want to use a DI (dependency injection) container, optionally with autowiring, to create a controller
rather than doing a simple `new`._
#### Dependency injection

You typically want to use a DI (dependency injection) container, optionally with autowiring, to create a controller
rather than doing a simple `new`.

```php
use App\Generated\InvokeMiddleware;

$container = new DI\Container();

$middleware[] = new InvokeMiddleware(fn($controllerClass) => $container->get($controllerClass));
```

### Error pages

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"source": "https://github.com/jasny/switch-route"
},
"require": {
"php": "^7.2.0 || ^8.0",
"php": "^8.1",
"jasny/reflection-factory": "^1.1.1",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
Expand All @@ -27,7 +27,7 @@
"jasny/php-code-quality": "~2.7.0",
"jasny/phpunit-extension": "~0.3.2",
"phpstan/phpstan": "~0.12.0",
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^9.3",
"nyholm/psr7": "^1.1",
"relay/relay": "^2.0"
},
Expand Down

0 comments on commit 87545bd

Please sign in to comment.