Nettrine

Nettrine

Easy & smart integration of Doctrine2 to Nette Framework

DBAL → ORM → Playground

# Installation

Add to your current project using composer.

composer require nettrine/dbal nettrine/orm
1

Or take a look at examples.

composer create-project --repository https://github.com/planette/playground
1

# Configuration

Setup your configuration in NEON files.

extensions:
	# General
	annotations: Nettrine\Annotations\DI\AnnotationsExtension

	# Dbal
	dbal: Nettrine\DBAL\DI\DbalExtension
	dbal.console: Nettrine\DBAL\DI\DbalConsoleExtension

	# Orm
	orm: Nettrine\ORM\DI\OrmExtension
	orm.cache: Nettrine\ORM\DI\OrmCacheExtension
	orm.console: Nettrine\ORM\DI\OrmConsoleExtension
	orm.annotations: Nettrine\ORM\DI\OrmAnnotationsExtension

dbal:
	debug:
		panel: %debugMode%
	connection:
		driver: pdo_mysql
		host: %database.host%
		user: %database.user%
		password: %database.password%
		dbname: %database.dbname%

orm:
	configuration:
		autoGenerateProxyClasses: %debugMode%

orm.annotations:
	mapping:
		App\Model: %appDir%/Model
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

Setup connection to database in config.local.neon.

parameters:
	database:
		host: localhost
		dbname: nutella
		user: nutella
		password: nutella
1
2
3
4
5
6

# Usage

<?php declare(strict_types = 1);

namespace App\Model;

use Doctrine\ORM\EntityManagerInterface;

final class Foobar
{
	private EntityManagerInterface $entityManager;

	public function __construct(EntityManagerInterface $entityManager)
	{
		$this->entityManager = $entityManager;
	}

	public function foo(): void
	{
		$user = $this->entityManager->getUserRepository()->findOneBy(['email' => 'milan@sulc.dev']);
	}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20