@@ -5,7 +5,7 @@ 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 )
@@ -20,9 +20,9 @@ This package can clean up your code, by getting rid of all the factories you wri
2020## Installation
2121
2222Run the following command in your project directory
23- ``` bash
24- $ composer require dotkernel/dot-annotated-services
25- ```
23+
24+ composer require dotkernel/dot-annotated-services
25+
2626
2727After installing, add the ` ConfigProvider ` class to your configuration aggregate.
2828
@@ -43,28 +43,30 @@ return [
4343
4444The next step is to annotate the service constructor or setters with the service names to inject
4545``` php
46- use Dot\AnnotatedServices\Annotation\Service;
4746use Dot\AnnotatedServices\Annotation\Inject;
4847
4948/**
50- * Service constructor
51- * @param Dependency1 $dep1
52- * ...
53- *
54- * @Inject({Dependency1::class, Dependency2::class, ... })
49+ * @Inject({
50+ * Dependency1::class,
51+ * Dependency2::class,
52+ * "config"
53+ * })
5554 */
56- public function __construct(Dependency1 $dep1, Dependency2 $dep2, ...)
57- {
58- $this->dep1 = $dep1;
59- //...
55+ public function __construct(
56+ protected Dependency1 $dep1,
57+ protected Dependency2 $dep2,
58+ protected array $config
59+ ) {
6060}
6161```
6262
6363The 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.
64+ Valid service names should be provided, as registered in the service manager.
6565
6666To inject an array value from the service manager, you can use dot notation as below
6767``` php
68+ use Dot\AnnotatedServices\Annotation\Inject;
69+
6870/**
6971 * @Inject({"config.debug"})
7072 */
@@ -93,6 +95,7 @@ The `name` field has to be the fully qualified class name.
9395Every repository should extend ` Doctrine\ORM\EntityRepository ` .
9496``` php
9597use Doctrine\ORM\EntityRepository;
98+ use Dot\AnnotatedServices\Annotation\Entity;
9699
97100/**
98101 * @Entity(name="App\Entity\Example")
@@ -111,7 +114,6 @@ Using this approach, no service manager configuration is required. It uses the r
111114In order to tell the abstract factory which services are to be created, you need to annotate the service class with the ` @Service ` annotation.
112115``` php
113116use Dot\AnnotatedServices\Annotation\Service;
114- use Dot\AnnotatedServices\Annotation\Inject;
115117
116118/*
117119 * @Service
0 commit comments