Skip to content

Commit bc7e0f5

Browse files
authored
Merge pull request #5 from dotkernel/develop
updated README.md
2 parents 765cc34 + 789f38a commit bc7e0f5

1 file changed

Lines changed: 38 additions & 3 deletions

File tree

README.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# dot-annotated-services
22

3-
DotKernel service creation component through zend-servicemanager and annotations
3+
DotKernel component used to create services through [Zend Service Manager](https://github.com/zendframework/zend-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.
4+
5+
This package can clean up your code, by getting rid of all the factories you write, sometimes just to inject a dependency or two.
6+
7+
**Requires PHP version >= 7.1**
48

59
## Installation
610

@@ -9,7 +13,7 @@ Run the following command in your project directory
913
$ composer require dotkernel/dot-annotated-services
1014
```
1115

12-
After installing, add `ConfigProvider` to your configuration.
16+
After installing, add the `ConfigProvider` class to your configuration aggregate.
1317

1418
## Usage
1519

@@ -84,4 +88,35 @@ And that's it, you don't need to configure the service manager with this class,
8488

8589
## Cache annotations
8690

87-
@TODO: write documentation
91+
This package is built on top of `doctrine/annotation` and `doctrine/cache`.
92+
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.
93+
94+
Below, we give an example, as defined in our frontend and admin starter applications
95+
```php
96+
return [
97+
'annotations_cache_dir' => __DIR__ . '/../../data/cache/annotations',
98+
'dependencies' => [
99+
'factories' => [
100+
// used by dot-annotated-services to cache annotations
101+
// needs to return a cache instance from Doctrine\Common\Cache
102+
AbstractAnnotatedFactory::CACHE_SERVICE => AnnotationsCacheFactory::class,
103+
]
104+
],
105+
];
106+
```
107+
108+
```php
109+
namespace Frontend\App\Factory;
110+
111+
use Doctrine\Common\Cache\FilesystemCache;
112+
use Psr\Container\ContainerInterface;
113+
114+
class AnnotationsCacheFactory
115+
{
116+
public function __invoke(ContainerInterface $container)
117+
{
118+
//change this to suite your caching needs
119+
return new FilesystemCache($container->get('config')['annotations_cache_dir']);
120+
}
121+
}
122+
```

0 commit comments

Comments
 (0)