Skip to content

Commit 1264cc2

Browse files
authored
Merge pull request #54 from dotkernel/issue-52-v4
Issue #51: `v4` active mode and support for PHP 8.4
2 parents b725578 + 41d0ab3 commit 1264cc2

27 files changed

+320
-201
lines changed

.github/workflows/codecov.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ jobs:
1515
- ubuntu-latest
1616

1717
php:
18-
- "8.1"
1918
- "8.2"
2019
- "8.3"
2120

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "Continuous Integration"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
tags:
8+
9+
jobs:
10+
ci:
11+
uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x

.github/workflows/cs-tests.yml

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

.github/workflows/static-analysis.yml

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

.github/workflows/unit-test.yml

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

.laminas-ci.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ignore_php_platform_requirements": {
3+
"8.4": true
4+
},
5+
"backwardCompatibilityCheck": true
6+
}

OSSMETADATA

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
osslifecycle=active
1+
osslifecycle=active

README.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
11
# dot-annotated-services
22

3-
DotKernel component used to create services through [Laminas Service Manager](https://github.com/laminas/laminas-servicemanager) and inject them with dependencies just using method annotations. It can also create services without the need to write factories. Annotation parsing can be cached, to improve performance.
3+
Dotkernel component used to create services through [Laminas Service Manager](https://github.com/laminas/laminas-servicemanager) and inject them with dependencies just using method annotations. It can also create services without the need to write factories. Annotation parsing can be cached, to improve performance.
44

55
This package can clean up your code, by getting rid of all the factories you write, sometimes just to inject a dependency or two.
66

7-
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-annotated-services)
8-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.1.7)
7+
![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fdot-annotated-services%2Fblob%2F4.0%2FOSSMETADATA)
8+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.2.0)
99

1010
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/issues)
1111
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/network)
1212
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/stargazers)
1313
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/blob/4.0/LICENSE.md)
1414

15-
[![Build Static](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/static-analysis.yml)
15+
[![Build Static](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-annotated-services/actions/workflows/continuous-integration.yml)
1616
[![codecov](https://codecov.io/gh/dotkernel/dot-annotated-services/graph/badge.svg?token=ZBZDEA3LY8)](https://codecov.io/gh/dotkernel/dot-annotated-services)
1717

18-
[![SymfonyInsight](https://insight.symfony.com/projects/a0d7016e-fc3f-46b8-9b36-571ff060d744/big.svg)](https://insight.symfony.com/projects/a0d7016e-fc3f-46b8-9b36-571ff060d744)
19-
20-
2118
## Installation
2219

2320
Run the following command in your project directory
2421

25-
composer require dotkernel/dot-annotated-services
26-
22+
```shell
23+
composer require dotkernel/dot-annotated-services
24+
```
2725

2826
After installing, add the `ConfigProvider` class to your configuration aggregate.
2927

3028
## Usage
3129

3230
### Using the AnnotatedServiceFactory
3331

34-
You can register services in the service manager using the `AnnotatedServiceFactory` as below
32+
You can register services in the service manager using the `AnnotatedServiceFactory` as below.
33+
3534
```php
3635
return [
3736
'factories' => [
@@ -40,10 +39,10 @@ return [
4039
];
4140
```
4241

43-
### NOTE
44-
> You can use only the fully qualified class name as the service key
42+
> You can use only the fully qualified class name as the service key.
43+
44+
The next step is to annotate the service constructor or setters with the service names to inject.
4545

46-
The next step is to annotate the service constructor or setters with the service names to inject
4746
```php
4847
use Dot\AnnotatedServices\Annotation\Inject;
4948

@@ -65,7 +64,8 @@ public function __construct(
6564
The annotation `@Inject` is telling the factory to inject the services between curly braces.
6665
Valid service names should be provided, as registered in the service manager.
6766

68-
To inject an array value from the service manager, you can use dot notation as below
67+
To inject an array value from the service manager, you can use dot notation as below,
68+
6969
```php
7070
use Dot\AnnotatedServices\Annotation\Inject;
7171

@@ -76,13 +76,14 @@ use Dot\AnnotatedServices\Annotation\Inject;
7676

7777
which will inject `$container->get('config')['debug'];`
7878

79-
### NOTE
80-
> Even if using dot annotation, the annotated factory will check first if a service name exists with that name
79+
> Even if using dot annotation, the annotated factory will check first if a service name exists with that name.
8180
8281
You can use the inject annotation on setters too, they will be called at creation time and injected with the configured dependencies.
8382

84-
### Using the AnnotatedRepositoryFactory
85-
You can register doctrine repositories and inject them using the AnnotatedRepositoryFactory as below:
83+
### Using the AnnotatedRepositoryFactory
84+
85+
You can register doctrine repositories and inject them using the AnnotatedRepositoryFactory as below.
86+
8687
```php
8788
return [
8889
'factories' => [
@@ -96,6 +97,7 @@ The next step is to add the `@Entity` annotation in the repository class.
9697
The `name` field has to be the fully qualified class name.
9798

9899
Every repository should extend `Doctrine\ORM\EntityRepository`.
100+
99101
```php
100102
use Doctrine\ORM\EntityRepository;
101103
use Dot\AnnotatedServices\Annotation\Entity;
@@ -105,16 +107,15 @@ use Dot\AnnotatedServices\Annotation\Entity;
105107
*/
106108
class ExampleRepository extends EntityRepository
107109
{
108-
109110
}
110111
```
111112

112-
113113
### Using the abstract factory
114114

115115
Using this approach, no service manager configuration is required. It uses the registered abstract factory to create annotated services.
116116

117117
In order to tell the abstract factory which services are to be created, you need to annotate the service class with the `@Service` annotation.
118+
118119
```php
119120
use Dot\AnnotatedServices\Annotation\Service;
120121

@@ -129,13 +130,14 @@ class ServiceClass
129130

130131
And that's it, you don't need to configure the service manager with this class, creation will happen automatically.
131132

132-
133133
## Cache annotations
134134

135135
This package is built on top of `doctrine/annotation` and `doctrine/cache`.
136-
In order to cache annotations, you should register a service factory at key `AbstractAnnotatedFactory::CACHE_SERVICE` that should return a valid `Doctrine\Common\Cache\Cache` cache driver. See [Cache Drivers](https://github.com/doctrine/cache/tree/master/lib/Doctrine/Common/Cache) for available implementations offered by doctrine.
136+
In order to cache annotations, you should register a service factory at key `AbstractAnnotatedFactory::CACHE_SERVICE` that should return a valid `Doctrine\Common\Cache\Cache` cache driver.
137+
See [Cache Drivers](https://github.com/doctrine/cache/tree/master/lib/Doctrine/Common/Cache) for available implementations offered by doctrine.
138+
139+
Below, we give an example, as defined in our frontend and admin starter applications:
137140

138-
Below, we give an example, as defined in our frontend and admin starter applications
139141
```php
140142
return [
141143
'annotations_cache_dir' => __DIR__ . '/../../data/cache/annotations',

SECURITY.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
6+
| Version | Supported | PHP Version |
7+
|---------|--------------------|------------------------------------------------------------------------------------------------------------------------|
8+
| 5.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/5.2.0) |
9+
| 4.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.2.0) |
10+
| <= 3.x | :x: | |
11+
12+
13+
## Reporting Potential Security Issues
14+
15+
If you have encountered a potential security vulnerability in this project,
16+
please report it to us at <security@dotkernel.com>. We will work with you to
17+
verify the vulnerability and patch it.
18+
19+
When reporting issues, please provide the following information:
20+
21+
- Component(s) affected
22+
- A description indicating how to reproduce the issue
23+
- A summary of the security vulnerability and impact
24+
25+
We request that you contact us via the email address above and give the
26+
project contributors a chance to resolve the vulnerability and issue a new
27+
release prior to any public exposure; this helps protect the project's
28+
users, and provides them with a chance to upgrade and/or update in order to
29+
protect their applications.
30+
31+
32+
## Policy
33+
34+
If we verify a reported security vulnerability, our policy is:
35+
36+
- We will patch the current release branch, as well as the immediate prior minor
37+
release branch.
38+
39+
- After patching the release branches, we will immediately issue new security
40+
fix releases for each patched release branch.

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
"service-manager"
2121
],
2222
"require": {
23-
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
23+
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
2424
"laminas/laminas-servicemanager": "^3.22.1",
2525
"doctrine/annotations": "^1.14.3",
2626
"doctrine/cache": "^1.12.1 || ^2.1.1",
27-
"doctrine/orm" : "^2.17.3"
27+
"doctrine/orm" : "^2.20"
2828
},
2929
"require-dev": {
3030
"phpunit/phpunit": "^10.5.9",
3131
"vimeo/psalm": "^5.20",
32-
"laminas/laminas-coding-standard": "^2.5"
32+
"laminas/laminas-coding-standard": "^3.0"
3333
},
3434
"autoload": {
3535
"psr-4": {

0 commit comments

Comments
 (0)