Nettrine

Easy & smart integration of Doctrine2 to Nette Framework

Check it out →

Installation

Create new project using composer library.

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

Add to your current project using composer library.

composer require nettrine/dbal nettrine/orm
1

Configuration

Setup your configuration in NEON files.

extensions:

	# 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: %debugMode%
	connection:
		driver: %database.driver%
		host: %database.host%
		user: %database.user%
		password: %database.password%
		dbname: %database.dbname%

orm:
	configuration:
		autoGenerateProxyClasses: %debugMode%

orm.annotations:
	debug: %debugMode%
	paths:
		- %appDir%/model/Database/Entity

orm.cache:
	defaultDriver: apcu
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
32

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 App\Model\Database\EntityManager;

final class Foobar
{

	/** @var EntityManager */
	private $em;

	public function __construct(EntityManager $em)
	{
		$this->em = $em;
	}

  public function foo():
  {
    $user = $this->em->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
21
22
23