@@ -5,24 +5,25 @@ DotKernel component used to create services through [Laminas Service Manager](ht
55This package can clean up your code, by getting rid of all the factories you write, sometimes just to inject a dependency or two.
66
77![ 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.0 )
8+ ![ PHP from Packagist (specify version)] ( https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.1.3 )
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
1515[ ![ 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 )
16+ [ ![ codecov] ( https://codecov.io/gh/dotkernel/dot-annotated-services/graph/badge.svg?token=ZBZDEA3LY8 )] ( https://codecov.io/gh/dotkernel/dot-annotated-services )
1617
1718[ ![ SymfonyInsight] ( https://insight.symfony.com/projects/a0d7016e-fc3f-46b8-9b36-571ff060d744/big.svg )] ( https://insight.symfony.com/projects/a0d7016e-fc3f-46b8-9b36-571ff060d744 )
1819
1920
2021## Installation
2122
2223Run the following command in your project directory
23- ``` bash
24- $ composer require dotkernel/dot-annotated-services
25- ```
24+
25+ composer require dotkernel/dot-annotated-services
26+
2627
2728After installing, add the ` ConfigProvider ` class to your configuration aggregate.
2829
@@ -43,28 +44,30 @@ return [
4344
4445The next step is to annotate the service constructor or setters with the service names to inject
4546``` php
46- use Dot\AnnotatedServices\Annotation\Service;
4747use Dot\AnnotatedServices\Annotation\Inject;
4848
4949/**
50- * Service constructor
51- * @param Dependency1 $dep1
52- * ...
53- *
54- * @Inject({Dependency1::class, Dependency2::class, ... })
50+ * @Inject({
51+ * Dependency1::class,
52+ * Dependency2::class,
53+ * "config"
54+ * })
5555 */
56- public function __construct(Dependency1 $dep1, Dependency2 $dep2, ...)
57- {
58- $this->dep1 = $dep1;
59- //...
56+ public function __construct(
57+ protected Dependency1 $dep1,
58+ protected Dependency2 $dep2,
59+ protected array $config
60+ ) {
6061}
6162```
6263
6364The annotation ` @Inject ` is telling the factory to inject the services between curly braces.
64- Valid service names should be provided, as registerd in the service manager.
65+ Valid service names should be provided, as registered in the service manager.
6566
6667To inject an array value from the service manager, you can use dot notation as below
6768``` php
69+ use Dot\AnnotatedServices\Annotation\Inject;
70+
6871/**
6972 * @Inject({"config.debug"})
7073 */
@@ -93,6 +96,7 @@ The `name` field has to be the fully qualified class name.
9396Every repository should extend ` Doctrine\ORM\EntityRepository ` .
9497``` php
9598use Doctrine\ORM\EntityRepository;
99+ use Dot\AnnotatedServices\Annotation\Entity;
96100
97101/**
98102 * @Entity(name="App\Entity\Example")
@@ -111,7 +115,6 @@ Using this approach, no service manager configuration is required. It uses the r
111115In order to tell the abstract factory which services are to be created, you need to annotate the service class with the ` @Service ` annotation.
112116``` php
113117use Dot\AnnotatedServices\Annotation\Service;
114- use Dot\AnnotatedServices\Annotation\Inject;
115118
116119/*
117120 * @Service
0 commit comments