Skip to content

Commit a8fa097

Browse files
committed
Docs: rework
1 parent f03f360 commit a8fa097

File tree

1 file changed

+53
-49
lines changed

1 file changed

+53
-49
lines changed

.docs/README.md

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,44 @@
11
# Contributte Doctrine Annotations
22

3-
[Doctrine/Annotations](https://www.doctrine-project.org/projects/annotations.html) for Nette Framework.
4-
3+
Integration of [Doctrine Annotations](https://www.doctrine-project.org/projects/annotations.html) for Nette Framework.
54

65
## Content
76

8-
- [Setup](#setup)
9-
- [Relying](#relying)
7+
- [Installation](#installation)
108
- [Configuration](#configuration)
9+
- [Minimal configuration](#minimal-configuration)
10+
- [Advanced configuration](#advanced-configuration)
11+
- [Caching](#caching)
1112
- [Usage](#usage)
12-
- [Examples](#examples)
13-
1413

15-
## Setup
14+
## Installation
1615

17-
Install package
16+
Install package using composer.
1817

1918
```bash
2019
composer require nettrine/annotations
2120
```
2221

23-
Register extension
22+
Register prepared [compiler extension](https://doc.nette.org/en/dependency-injection/nette-container) in your `config.neon` file.
2423

2524
```yaml
2625
extensions:
2726
nettrine.annotations: Nettrine\Annotations\DI\AnnotationsExtension
2827
```
2928
29+
> [!NOTE]
30+
> This is just **Annotations**, for **ORM** use [nettrine/orm](https://github.com/contributte/doctrine-orm) or **DBAL** use [nettrine/dbal](https://github.com/contributte/doctrine-dbal).
3031
31-
## Relying
32-
33-
Take advantage of empowering this package with 1 extra package:
34-
35-
- `doctrine/cache`
36-
37-
38-
### `doctrine/cache`
32+
## Configuration
3933
40-
This package can be enhanced with `doctrine/cache`, use prepared [nettrine/cache](https://github.com/contributte/doctrine-cache) integration.
34+
### Minimal configuration
4135
42-
```bash
43-
composer require nettrine/cache
44-
```
45-
46-
```yaml
47-
extensions:
48-
nettrine.cache: Nettrine\Cache\DI\CacheExtension
36+
```neon
37+
nettrine.annotations:
38+
debug: %debugMode%
4939
```
5040
51-
52-
## Configuration
53-
54-
**Schema definition**
41+
### Advanced configuration
5542
5643
```yaml
5744
nettrine.annotations:
@@ -60,7 +47,7 @@ nettrine.annotations:
6047
cache: <class|service>
6148
```
6249
63-
**Under the hood**
50+
**Example**
6451
6552
```yaml
6653
nettrine.annotations:
@@ -69,22 +56,13 @@ nettrine.annotations:
6956
cache: Doctrine\Common\Cache\PhpFileCache(%tempDir%/cache/doctrine)
7057
```
7158
72-
You may omit the `cache` key using [nettrine/cache](https://github.com/contributte/doctrine-cache) to setup cache. It's configured automatically.
73-
74-
```yaml
75-
nettrine.annotations:
76-
debug: %debugMode%
77-
```
78-
79-
8059
## Usage
8160
82-
You can count on [Nette Dependency Injection](https://doc.nette.org/en/3.0/dependency-injection).
83-
8461
```php
8562
use Doctrine\Common\Annotations\Reader;
8663

87-
class MyReader {
64+
class MyReader
65+
{
8866

8967
/** @var Reader */
9068
private $reader;
@@ -102,17 +80,43 @@ class MyReader {
10280
}
10381
```
10482

105-
Register reader `MyReader` under services in NEON file.
83+
You can create, define and read your own annotations. Take a look [how to do that](https://www.doctrine-project.org/projects/doctrine-annotations/en/2.0/index.html).
10684

107-
```yaml
108-
services:
109-
- MyReader
110-
```
85+
### Caching
86+
87+
> [!TIP]
88+
> Take a look at more information in official Doctrine documentation:
89+
> - https://www.doctrine-project.org/projects/annotations.html
90+
91+
A Doctrine Annotations reader can be very slow because it needs to parse all your entities and their annotations.
92+
93+
> [!WARNING]
94+
> Cache adapter must implement `Psr\Cache\CacheItemPoolInterface` interface.
95+
> Use any PSR-6 + PSR-16 compatible cache library like `symfony/cache` or `nette/caching`.
11196
112-
You can create, define and read your own annotations. Take a look [how to do that](https://www.doctrine-project.org/projects/doctrine-annotations/en/latest/index.html#create-an-annotation-class).
97+
In the simplest case, you can define only `cache`.
98+
99+
```neon
100+
nettrine.annotations:
101+
# Create cache manually
102+
cache: App\CacheService(%tempDir%/cache/orm)
103+
104+
# Use registered cache service
105+
cache: @cacheService
106+
```
113107

108+
> [!IMPORTANT]
109+
> You should always use cache for production environment. It can significantly improve performance of your application.
110+
> Pick the right cache adapter for your needs.
111+
> For example from symfony/cache:
112+
>
113+
> - `FilesystemAdapter` - if you want to cache data on disk
114+
> - `ArrayAdapter` - if you want to cache data in memory
115+
> - `ApcuAdapter` - if you want to cache data in memory and share it between requests
116+
> - `RedisAdapter` - if you want to cache data in memory and share it between requests and servers
117+
> - `ChainAdapter` - if you want to cache data in multiple storages
114118
115119
## Examples
116120

117-
- https://github.com/contributte/playground (playground)
118-
- https://contributte.org/examples.html (more examples)
121+
> [!TIP]
122+
> Take a look at more examples in [contributte/doctrine](https://github.com/contributte/doctrine/tree/master/.docs).

0 commit comments

Comments
 (0)