Contributte Doctrine-annotations
Doctrine/Annotations (opens new window) for Nette Framework.
# Content
# Setup
Install package
composer require nettrine/annotations
1
Register extension
extensions:
nettrine.annotations: Nettrine\Annotations\DI\AnnotationsExtension
1
2
2
# Relying
Take advantage of empowering this package with 1 extra package:
doctrine/cache
# doctrine/cache
This package can be enhanced with doctrine/cache
, use prepared nettrine/cache (opens new window) integration.
composer require nettrine/cache
1
extensions:
nettrine.cache: Nettrine\Cache\DI\CacheExtension
1
2
2
# Configuration
Schema definition
nettrine.annotations:
debug: <boolean>
ignore: <string[]>
cache: <class|service>
1
2
3
4
2
3
4
Under the hood
nettrine.annotations:
debug: %debugMode%
ignore: [author, since, see]
cache: Doctrine\Common\Cache\PhpFileCache(%tempDir%/cache/doctrine)
1
2
3
4
2
3
4
You may omit the cache
key using nettrine/cache (opens new window) to setup cache. It's configured automatically.
nettrine.annotations:
debug: %debugMode%
1
2
2
# Usage
You can count on Nette Dependency Injection (opens new window).
use Doctrine\Common\Annotations\Reader;
class MyReader {
/** @var Reader */
private $reader;
public function __construct(Reader $reader)
{
$this->reader = $reader;
}
public function reader()
{
$annotations = $this->reader->getClassAnnotations(new \ReflectionClass(UserEntity::class));
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Register reader MyReader
under services in NEON file.
services:
- MyReader
1
2
2
You can create, define and read your own annotations. Take a look how to do that (opens new window).
# Examples
- https://github.com/contributte/playground (opens new window) (playground)
- https://contributte.org/examples.html (opens new window) (more examples)