Skip to content

Commit 0efdd5c

Browse files
authored
Merge pull request #51 from dotkernel/issue-49
Issue #49: Remove PHP 8.1 and add PHP 8.4 & 8.5 support
2 parents 5a40757 + c2a0d90 commit 0efdd5c

File tree

16 files changed

+124
-86
lines changed

16 files changed

+124
-86
lines changed

.github/workflows/codecov.yml

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

1717
php:
18-
- "8.1"
1918
- "8.2"
2019
- "8.3"
2120
- "8.4"
21+
- "8.5"
2222

2323
steps:
2424
- name: Checkout

.github/workflows/static-analysis.yml

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

1717
php:
18-
- "8.1"
1918
- "8.2"
2019
- "8.3"
2120
- "8.4"
21+
- "8.5"
2222

2323
steps:
2424
- name: Checkout

README.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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.
5-
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.
66

77
## Documentation
88

@@ -11,7 +11,7 @@ Documentation is available at: https://docs.dotkernel.org/dot-controller/.
1111
## Badges
1212

1313
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-controller)
14-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/4.1.0)
14+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/4.2.0)
1515

1616
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/issues)
1717
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/network)
@@ -32,17 +32,22 @@ composer require dotkernel/dot-controller
3232

3333
## Usage
3434

35-
Middleware controllers act as a handler for multiple routes. Some conventions were made:
35+
Middleware controllers act as a handler for multiple routes.
36+
Some conventions were made:
3637

37-
- 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}]`)
38-
- 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`.
38+
- register controllers in the `routes` array just like any Mezzio middleware.
39+
The requirement is that you should define an `action` route parameter (possibly optional) anywhere inside the route (e.g `/user[/{action}]`).
40+
- action parameter value is converted to a method name inside the controller.
41+
Underscore, dot and line characters are removed and the action name is converted to a camel-case suffixed by the string `Action`.
42+
For example, a route and action pair like `/user/forgot-password` will be converted to method `forgotPasswordAction`.
3943
- 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.
4044

41-
In order to create your action based controllers, you must extend the abstract class `Dot\Controller\AbstractActionController`.
45+
To create your action-based controllers, you must extend the abstract class `Dot\Controller\AbstractActionController`.
4246

4347
### Example
4448

45-
Creating a UserController with default action and a register action. Will handle routes `/user` and `/user/register`.
49+
Creating a UserController with a default action and a register action.
50+
Will handle routes `/user` and `/user/register`.
4651

4752
```php
4853
use Dot\Controller\AbstractActionController;
@@ -61,7 +66,7 @@ class UserController extends AbstractActionController
6166
}
6267
```
6368

64-
Then register this controller as a routed middleware in file `RoutesDelegator.php` just like a regular middleware.
69+
Then register this controller as routed middleware in file `RoutesDelegator.php` just like regular middleware.
6570

6671
```php
6772
//Example from a RoutesDelegator
@@ -77,13 +82,13 @@ $app->route(
7782

7883
**Use case:**
7984
You have defined a controller inside some package, with default actions.
80-
You want to add actions that fall into the same controller name(or route name more exactly).
85+
You want to add actions that fall into the same controller name (or route name more exactly).
8186
You want to do this without extending the controller provided by the package.
8287
In this case you can do the following:
8388

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

8792
Now when a request for this route comes in, your controller will run first.
8893
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.
89-
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).
94+
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: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
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+
| 4.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/4.2.0) |
8+
| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/3.6.0) |
99
| <= 2.x | :x: | |
1010

11-
1211
## Reporting Potential Security Issues
1312

1413
If you have encountered a potential security vulnerability in this project,
@@ -24,10 +23,9 @@ When reporting issues, please provide the following information:
2423
We request that you contact us via the email address above and give the
2524
project contributors a chance to resolve the vulnerability and issue a new
2625
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
26+
users and provides them with a chance to upgrade and/or update to
2827
protect their applications.
2928

30-
3129
## Policy
3230

3331
If we verify a reported security vulnerability, our policy is:

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919
],
2020
"require": {
21-
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
21+
"php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
2222
"dotkernel/dot-event": "^4.0.0",
2323
"laminas/laminas-servicemanager": "^4.0",
2424
"mezzio/mezzio-helpers": "^5.8.0",
@@ -50,8 +50,8 @@
5050
],
5151
"cs-check": "phpcs",
5252
"cs-fix": "phpcbf",
53-
"test": "phpunit --colors=always",
54-
"static-analysis": "phpstan analyse --memory-limit 1G"
53+
"static-analysis": "phpstan analyse --memory-limit 1G",
54+
"test": "phpunit --colors=always"
5555
},
5656
"config": {
5757
"sort-packages": true,

docs/book/v3/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Configuration
22

3-
After installation, the package can be used immediately but if you want to use all features of the package, like plugins and events you need to register the `ConfigProvider` in your project by adding the below line to your configuration aggregator (usually: `config/config.php`):
3+
After installation, the package can be used immediately but if you want to use all features of the package, like plugins and events, you need to register the `ConfigProvider` in your project by adding the below line to your configuration aggregator (usually: `config/config.php`):
44

55
```php
66
\Dot\Controller\ConfigProvider::class,

docs/book/v3/events.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# Events
22

3-
Dotkernel's controller package supports events and those events can be of 2 types: global events (middleware-like) or manually dispatch events.
3+
Dotkernel's controller package supports events, and those events can be of two types: global events (middleware-like) or manually dispatched events.
44

55
## Getting started
66

7-
- Every event listener that is triggered from a controller needs to implement `Dot\Controller\Event\ControllerEventListenerInterface` which actually extends `Laminas\EventManager\ListenerAggregateInterface`.
7+
- Every event listener triggered from a controller needs to implement `Dot\Controller\Event\ControllerEventListenerInterface` which actually extends `Laminas\EventManager\ListenerAggregateInterface`.
88
- You can add the trait `Dot\Controller\Event\ControllerEventListenerTrait` to override the method of the interface.
99
- Every event listener needs to be registered under the `['dot_controller']['event_listenenrs]` key in the ConfigProvider, and every key must be the class that you want to attach the events.
1010

1111
## Usage
1212

13-
The events in a controller can be done in 2 different ways, a global way where an event is attached automatically to all the controllers action and works in the same way the middlewares works or a manually dispatchable way, where you can define to which controller the events is attached, and you can trigger the event where you want.
14-
For our example we have a UserController with some methods in it:
13+
The events in a controller can be done in two different ways:
14+
15+
- a global way where an event is attached automatically to all the controller actions and works in the same way the middlewares works
16+
- in a manually dispatchable way, where you can define to which controller the events are attached, and you can trigger the event where you want
17+
18+
For our example, we have a UserController with some methods in it:
1519

1620
```php
1721
use Dotkernel\DotController\AbstractActionController;
@@ -36,9 +40,9 @@ class UserController extends AbstractActionController
3640
}
3741
```
3842

39-
### Example 1 - Global way
43+
### Global method
4044

41-
First we will create the event listener:
45+
First, we will create the event listener:
4246

4347
```php
4448
use Dot\Controller\Event\ControllerEvent;
@@ -98,7 +102,7 @@ public function onAfterDispatch(ControllerEvent $e): void
98102
So every time the `updateAction` is accessed and the method is post, right after the action is dispatched, we can log that the user was updated.
99103
We can use the `onBeforeDispatch` in the same way, to log right before the user is updated.
100104

101-
### Example 2 - Manually triggered way
105+
### Manual method
102106

103107
```php
104108
use Dot\Controller\Event\ControllerEvent;
@@ -128,7 +132,7 @@ class UserUpdatedListener implements ControllerEventListenerInterface
128132
}
129133
```
130134

131-
The `attach` method is from the `ListenerAggregateInterface` which `ControllerEventListenerTrait` already is overriding it so can be used in a global way with `onBeforeDispatch` and `onAfterDispatch` methods, but we can make our custom event and bind it to our method.
135+
The `attach` method is from the `ListenerAggregateInterface` which `ControllerEventListenerTrait` already is overriding it so can be used globally with `onBeforeDispatch` and `onAfterDispatch` methods, but we can make our custom event and bind it to our method.
132136
In this case we create attach an event called `user.profile.update` and bind it to the `userProfileUpdated` method.
133137

134138
Next, we need to register the event:
@@ -137,7 +141,7 @@ Next, we need to register the event:
137141
'dot_controller' => [
138142
'event_listeners' => [
139143
AccountController::class => [
140-
'user.profile.update' => UserUpdatedListener::class
144+
'user.profile.update' => UserUpdatedListener::class,
141145
]
142146
]
143147
]
@@ -147,7 +151,7 @@ Now you can manually trigger the event from the controller using build in `dispa
147151

148152
```php
149153
// UserController
150-
// post method for updating the user
154+
// POST method for updating the user
151155
public function updateAction()
152156
{
153157
// logic

docs/book/v3/overview.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Overview
22

33
`dot-controller` 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.
5-
It is more lightweight though, but supports controller plugins and event listeners.
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+
## Badges
8+
9+
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-controller)
10+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/3.6.0)
11+
12+
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/issues)
13+
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/network)
14+
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/stargazers)
15+
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/blob/3.0/LICENSE.md)
16+
17+
[![Build Static](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml)
18+
[![codecov](https://codecov.io/gh/dotkernel/dot-controller/graph/badge.svg?token=VUBG5LM4CK)](https://codecov.io/gh/dotkernel/dot-controller)
19+
[![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)

docs/book/v3/plugins.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# Plugins
22

3-
Dotkernel's controller support plugins, much like controllers in Laminas applications.
4-
The package comes packed with a few built in plugins, but you can extend controller functionality with your own plugins.
3+
Dotkernel's controller supports plugins, much like controllers in Laminas applications.
4+
The package comes packed with a few built-in plugins, but you can extend controller functionality with your own plugins.
55

66
## Usage
77

88
Any controller plugins must implement `Dot\Controller\Plugin\PluginInterface`.
99
You need to create a factory in addition to the plugin and register it under the `['dot_controller']['plugin_manager']['factories']` with the plugin name.
1010

11-
Once registered, a plugin can be directly accessed in any controller, by calling a method with the plugin's name (the service name or the key at which the plugin is registered inside the manager).
11+
Once registered, a plugin can be directly accessed in any controller by calling a method with the plugin's name (the service name or the key at which the plugin is registered inside the manager).
1212

13-
Controller plugins offer the advantage of globally accessible functionality in any controller without to manually inject dependencies.
13+
Controller plugins offer the advantage of globally accessible functionality in any controller without manually injecting dependencies.
1414
Plugins should be used for functions that are common to any controller.
1515
Do not clutter controller's code with unnecessary plugins.
1616

1717
### Example
1818

19-
First we create our desired plugin, for our example a string helper:
19+
First we create our desired plugin, for our example, a string helper:
2020

2121
```php
2222
class StringPlugin implements PluginInterface
@@ -58,7 +58,7 @@ Register the factory under the `['dot_controller']['plugin_manager']['factories'
5858
]
5959
```
6060

61-
You don't need to register the plugin factory to a regular dependencies in a configuration because `AbstractPluginManager` actually extends `ServiceManager`.
61+
You don't need to register the plugin factory to a regular dependency in a configuration because `AbstractPluginManager` actually extends `ServiceManager`.
6262
Access it in a controller:
6363

6464
```php
@@ -67,9 +67,9 @@ $this->string(); // will return the StringPlugin class, so you can call any publ
6767
$this->string()->toUpper("test") // will return TEST
6868
```
6969

70-
## Build-in plugins
70+
## Built-in plugins
7171

72-
The package comes in with 2 default plugins ``template`` and `url`.
72+
The package comes in with two default plugins `template` and `url`.
7373
You can use them in the same way as our example above.
7474

7575
- `url` - the plugin is an instance of `Mezzio\Helper\UrlHelper`:

0 commit comments

Comments
 (0)