Skip to content

Commit e5df86c

Browse files
committed
Issue #48: Remove PHP 8.1 and add PHP 8.4 & 8.5 support
Signed-off-by: alexmerlin <[email protected]>
1 parent 6333a1f commit e5df86c

20 files changed

+118
-449
lines changed

.github/workflows/codecov.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ jobs:
1515
- ubuntu-latest
1616

1717
php:
18-
- "8.1"
1918
- "8.2"
2019
- "8.3"
20+
- "8.4"
21+
- "8.5"
2122

2223
steps:
2324
- name: Checkout

.github/workflows/docs-build.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
on:
2+
- push
3+
4+
name: Run PHPStan checks
5+
6+
jobs:
7+
mutation:
8+
name: PHPStan ${{ matrix.php }}-${{ matrix.os }}
9+
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
17+
php:
18+
- "8.2"
19+
- "8.3"
20+
- "8.4"
21+
- "8.5"
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Install PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: "${{ matrix.php }}"
31+
coverage: pcov
32+
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
33+
tools: composer:v2, cs2pr
34+
35+
- name: Determine composer cache directory
36+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
37+
38+
- name: Cache dependencies installed with composer
39+
uses: actions/cache@v4
40+
with:
41+
path: ${{ env.COMPOSER_CACHE_DIR }}
42+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
43+
restore-keys: |
44+
php${{ matrix.php }}-composer-
45+
46+
- name: Install dependencies with composer
47+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
48+
49+
- name: Run static analysis with PHPStan
50+
run: vendor/bin/phpstan analyse

README.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
# dot-controller
22

3-
This is DotKernel's controller package that can be use like middleware inside DotKernel or Mezzio application.
4-
It provides base classes for action based controllers similar to Laminas controller component. It is more lightweight though, but supports controller plugins and event listeners
3+
This is Dotkernel's controller package that can be used like middleware inside Dotkernel or Mezzio application.
4+
It provides base classes for action-based controllers similar to a Laminas controller component.
5+
It is more lightweight, though, but supports controller plugins and event listeners.
6+
7+
## Documentation
8+
9+
Documentation is available at: https://docs.dotkernel.org/dot-controller/v3/overview/.
10+
11+
## Badges
512

613
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-controller)
7-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/3.4.3)
14+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/3.6.0)
815

916
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/issues)
1017
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/network)
@@ -13,33 +20,35 @@ It provides base classes for action based controllers similar to Laminas control
1320

1421
[![Build Static](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml)
1522
[![codecov](https://codecov.io/gh/dotkernel/dot-controller/graph/badge.svg?token=VUBG5LM4CK)](https://codecov.io/gh/dotkernel/dot-controller)
16-
17-
[![SymfonyInsight](https://insight.symfony.com/projects/c4aac671-40d7-4590-b1fa-b3e46a1e3f43/big.svg)](https://insight.symfony.com/projects/c4aac671-40d7-4590-b1fa-b3e46a1e3f43)
23+
[![PHPStan](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml)
1824

1925
## Installation
2026

2127
Install `dot-controller` by executing the following Composer command:
2228

23-
```bash
24-
$ composer require dotkernel/dot-controller
29+
```shell
30+
composer require dotkernel/dot-controller
2531
```
2632

2733
## Usage
2834

2935
Middleware controllers act as a handler for multiple routes. Some conventions were made:
3036

31-
- register controllers in the routes array just like any mezzio middleware. The requirement is that you should define an `action` route parameter(possibly optional) anywhere inside the route(e.g `/user[/{action}]`)
32-
- action parameter value is converted to a method name inside the controller. Underscore, dot and line characters are removed and the action name is converted to camel-case suffixed by the string `Action`. For example a route and action pair like `/user/forgot-password` will be converted to method `forgotPasswordAction`.
37+
- register controllers in the `routes` array just like any mezzio middleware.
38+
The requirement is that you should define an `action` route parameter (possibly optional) anywhere inside the route (e.g `/user[/{action}]`).
39+
- action parameter value is converted to a method name inside the controller.
40+
Underscore, dot and line characters are removed and the action name is converted to a camel-case suffixed by the string `Action`.
41+
For example, a route and action pair like `/user/forgot-password` will be converted to method `forgotPasswordAction`.
3342
- the default action value, if not present in the URI is `index`, so you should always define an `indexAction` within your controllers for displaying a default page or redirecting.
3443

35-
In order to create your action based controllers, you must extend the abstract class `DotKernel\DotController\AbstractActionController`
44+
To create your action-based controllers, you must extend the abstract class `Dot\DotController\AbstractActionController`
3645

3746
### Example
3847

39-
Creating a UserController with default action and a register action. Will handle routes `/user` and `/user/register`
48+
Creating a UserController with a default action and a register action. Will handle routes `/user` and `/user/register`.
4049

4150
```php
42-
use DotKernel\DotController\AbstractActionController;
51+
use Dot\DotController\AbstractActionController;
4352

4453
class UserController extends AbstractActionController
4554
{
@@ -55,10 +64,10 @@ class UserController extends AbstractActionController
5564
}
5665
```
5766

58-
Then register this controller as a routed middleware in file `RoutesDelegator.php` just like a regular middleware.
67+
Then register this controller as routed middleware in file `RoutesDelegator.php` just like regular middleware.
5968

6069
```php
61-
//Example from a DotKernel RoutesDelegator
70+
// Example from a Dotkernel RoutesDelegator
6271
$app->route(
6372
'/user[/{action}]',
6473
UserController::class,
@@ -69,10 +78,13 @@ $app->route(
6978

7079
### Multiple controllers for the same route
7180

72-
Use case: You have defined a controller inside some package, with default actions. You want to add actions that fall into the same controller name(or route name more exactly). You want to do this without extending the controller provided by the package. In this case you can do the following
81+
Use case: You have defined a controller inside some package, with default actions. You want to add actions that fall into the same controller name (or route name more exactly).
82+
You want to do this without extending the controller provided by the package.
83+
In this case you can do the following:
7384

74-
- create your own controller, independent of the package's controller which adds more actions
85+
- create your own controller, independent of the package's controller, which adds more actions
7586
- Mezzio lets you define an array of middleware for a route, so you can register this controller before the package's controller
7687

77-
Now when a request for this route comes in, your controller will run first. DotKernel controllers are designed to ignore requests that cannot be matched to one of its methods, so if no action matches, it will call the next middleware, in our case, the second controller.
78-
If this is the last controller, and action does not match here, it will go to the default 404 Not found page(handled by NotFoundDelegate)
88+
Now when a request for this route comes in, your controller will run first.
89+
Dotkernel controllers are designed to ignore requests that cannot be matched to one of its methods, so if no action matches, it will call the next middleware, in our case, the second controller.
90+
If this is the last controller, and the action does not match here, it will go to the default 404 Not found page (handled by NotFoundDelegate).

SECURITY.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
## Supported Versions
44

5-
65
| Version | Supported | PHP Version |
76
|---------|--------------------|----------------------------------------------------------------------------------------------------------------|
8-
| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/3.4.3) |
7+
| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/3.6.0) |
98
| <= 2.x | :x: | |
109

11-
1210
## Reporting Potential Security Issues
1311

1412
If you have encountered a potential security vulnerability in this project,
@@ -24,7 +22,7 @@ When reporting issues, please provide the following information:
2422
We request that you contact us via the email address above and give the
2523
project contributors a chance to resolve the vulnerability and issue a new
2624
release prior to any public exposure; this helps protect the project's
27-
users, and provides them with a chance to upgrade and/or update in order to
25+
users and provides them with a chance to upgrade and/or update to
2826
protect their applications.
2927

3028

composer.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dotkernel/dot-controller",
33
"type": "library",
4-
"description": "DotKernel controller like middleware component with plugin support",
4+
"description": "Dotkernel controller like middleware component with plugin support",
55
"license": "MIT",
66
"homepage": "https://github.com/dotkernel/dot-controller",
77
"keywords": [
@@ -13,23 +13,24 @@
1313
],
1414
"authors": [
1515
{
16-
"name": "DotKernel Team",
16+
"name": "Dotkernel Team",
1717
"email": "[email protected]"
1818
}
1919
],
2020
"require": {
21-
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
22-
"psr/http-message": "^1.0 || ^2.0",
23-
"laminas/laminas-servicemanager": "^3.11.2",
21+
"php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
2422
"dotkernel/dot-event": "^3.2.0",
23+
"laminas/laminas-servicemanager": "^3.11.2",
2524
"mezzio/mezzio-template": "^2.4.0",
26-
"mezzio/mezzio-helpers": "^5.8.0"
25+
"mezzio/mezzio-helpers": "^5.8.0",
26+
"psr/http-message": "^1.0 || ^2.0"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "^10.2",
30-
"vimeo/psalm": "^5.13",
31-
"laminas/laminas-coding-standard": "^2.5",
32-
"laminas/laminas-diactoros": "^3.0"
29+
"laminas/laminas-coding-standard": "^3.0",
30+
"laminas/laminas-diactoros": "^3.0",
31+
"phpstan/phpstan": "^2.1",
32+
"phpstan/phpstan-phpunit": "^2.0",
33+
"phpunit/phpunit": "^10.2"
3334
},
3435
"autoload": {
3536
"psr-4": {
@@ -44,13 +45,13 @@
4445
"scripts": {
4546
"check": [
4647
"@cs-check",
47-
"@test"
48+
"@test",
49+
"@static-analysis"
4850
],
4951
"cs-check": "phpcs",
5052
"cs-fix": "phpcbf",
51-
"test": "phpunit --colors=always",
52-
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
53-
"static-analysis": "psalm --shepherd --stats"
53+
"static-analysis": "phpstan analyse --memory-limit 1G",
54+
"test": "phpunit --colors=always"
5455
},
5556
"config": {
5657
"sort-packages": true,

docs/book/index.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/book/v3/configuration.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)