diff --git a/.docs/README.md b/.docs/README.md deleted file mode 100755 index 10839cb..0000000 --- a/.docs/README.md +++ /dev/null @@ -1,122 +0,0 @@ -# Contributte Doctrine Annotations - -Integration of [Doctrine Annotations](https://www.doctrine-project.org/projects/annotations.html) for Nette Framework. - -## Content - -- [Installation](#installation) -- [Configuration](#configuration) - - [Minimal configuration](#minimal-configuration) - - [Advanced configuration](#advanced-configuration) - - [Caching](#caching) -- [Usage](#usage) - -## Installation - -Install package using composer. - -```bash -composer require nettrine/annotations -``` - -Register prepared [compiler extension](https://doc.nette.org/en/dependency-injection/nette-container) in your `config.neon` file. - -```yaml -extensions: - nettrine.annotations: Nettrine\Annotations\DI\AnnotationsExtension -``` - -> [!NOTE] -> 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). - -## Configuration - -### Minimal configuration - -```neon -nettrine.annotations: - debug: %debugMode% -``` - -### Advanced configuration - -```yaml -nettrine.annotations: - debug: - ignore: - cache: -``` - -**Example** - -```yaml -nettrine.annotations: - debug: %debugMode% - ignore: [author, since, see] - cache: Doctrine\Common\Cache\PhpFileCache(%tempDir%/cache/doctrine) -``` - -## Usage - -```php -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)); - } - -} -``` - -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). - -### Caching - -> [!TIP] -> Take a look at more information in official Doctrine documentation: -> - https://www.doctrine-project.org/projects/annotations.html - -A Doctrine Annotations reader can be very slow because it needs to parse all your entities and their annotations. - -> [!WARNING] -> Cache adapter must implement `Psr\Cache\CacheItemPoolInterface` interface. -> Use any PSR-6 + PSR-16 compatible cache library like `symfony/cache` or `nette/caching`. - -In the simplest case, you can define only `cache`. - -```neon -nettrine.annotations: - # Create cache manually - cache: App\CacheService(%tempDir%/cache/orm) - - # Use registered cache service - cache: @cacheService -``` - -> [!IMPORTANT] -> You should always use cache for production environment. It can significantly improve performance of your application. -> Pick the right cache adapter for your needs. -> For example from symfony/cache: -> -> - `FilesystemAdapter` - if you want to cache data on disk -> - `ArrayAdapter` - if you want to cache data in memory -> - `ApcuAdapter` - if you want to cache data in memory and share it between requests -> - `RedisAdapter` - if you want to cache data in memory and share it between requests and servers -> - `ChainAdapter` - if you want to cache data in multiple storages - -## Examples - -> [!TIP] -> Take a look at more examples in [contributte/doctrine](https://github.com/contributte/doctrine/tree/master/.docs). diff --git a/README.md b/README.md index f200e3f..90a3eba 100755 --- a/README.md +++ b/README.md @@ -18,25 +18,122 @@ Website 🚀 contributte.org | Contact 👨🏻‍💻 f3l1x.io | Twitter 🐦 @contributte

+Integration of [Doctrine Annotations](https://www.doctrine-project.org/projects/annotations.html) for Nette Framework. -## Usage +## Versions + +| State | Version | Branch | Nette | PHP | +|--------|---------|----------|--------|---------| +| dev | `^0.10` | `master` | `3.2+` | `>=8.2` | +| stable | `^0.9` | `master` | `3.2+` | `>=8.2` | + +## Installation To install the latest version of `nettrine/annotations` use [Composer](https://getcomposer.org). -``` +```bash composer require nettrine/annotations ``` -## Documentation +Register prepared [compiler extension](https://doc.nette.org/en/dependency-injection/nette-container) in your `config.neon` file. -For details on how to use this package, check out our [documentation](.docs). +```yaml +extensions: + nettrine.annotations: Nettrine\Annotations\DI\AnnotationsExtension +``` -## Versions +> [!NOTE] +> 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). -| State | Version | Branch | Nette | PHP | -|--------|---------|----------|--------|---------| -| dev | `^0.10` | `master` | `3.2+` | `>=8.2` | -| stable | `^0.9` | `master` | `3.2+` | `>=8.2` | +## Configuration + +### Minimal Configuration + +```neon +nettrine.annotations: + debug: %debugMode% +``` + +### Advanced Configuration + +```yaml +nettrine.annotations: + debug: + ignore: + cache: +``` + +**Example** + +```yaml +nettrine.annotations: + debug: %debugMode% + ignore: [author, since, see] + cache: Doctrine\Common\Cache\PhpFileCache(%tempDir%/cache/doctrine) +``` + +## Usage + +```php +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)); + } +} +``` + +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). + +### Caching + +> [!TIP] +> Take a look at more information in official Doctrine documentation: +> - https://www.doctrine-project.org/projects/annotations.html + +A Doctrine Annotations reader can be very slow because it needs to parse all your entities and their annotations. + +> [!WARNING] +> Cache adapter must implement `Psr\Cache\CacheItemPoolInterface` interface. +> Use any PSR-6 + PSR-16 compatible cache library like `symfony/cache` or `nette/caching`. + +In the simplest case, you can define only `cache`. + +```neon +nettrine.annotations: + # Create cache manually + cache: App\CacheService(%tempDir%/cache/orm) + + # Use registered cache service + cache: @cacheService +``` + +> [!IMPORTANT] +> You should always use cache for production environment. It can significantly improve performance of your application. +> Pick the right cache adapter for your needs. +> For example from symfony/cache: +> +> - `FilesystemAdapter` - if you want to cache data on disk +> - `ArrayAdapter` - if you want to cache data in memory +> - `ApcuAdapter` - if you want to cache data in memory and share it between requests +> - `RedisAdapter` - if you want to cache data in memory and share it between requests and servers +> - `ChainAdapter` - if you want to cache data in multiple storages + +## Examples + +> [!TIP] +> Take a look at more examples in [contributte/doctrine](https://github.com/contributte/doctrine/tree/master/.docs). ## Development