Statistics
510
1
0
110d
Badges
Requirements

Scrutinizer Code Quality

nette-doctrine

A lightweight Doctrine integration extension for Nette framework. This extension is a replacement of Kdyby\Doctrine, suitable for those who want to use native Doctrine classes and don't want register entity manager in the Nette service container themselves. It is compatible with Kdyby\Console.

Configuration

Add extension to Nette project like this:

extensions:
	doctrine: DTForce\DoctrineExtension\DI\DoctrineExtension

Configure Doctrine access and other parameters like this:

doctrine:
	connection:
		driver: pdo_pgsql
		host: localhost
		port: 5432
		user: username
		password: password
		dbname: database

	debug: true
	prefix: doctrine.default
	proxyDir: %tempDir%/cache/proxies
	sourceDir: %appDir%/Entity

	dbal:
		types:
			dateinterval: App\Doctrine\Postgresql\Types\DateIntervalType
		type_overrides:
			date: VasekPurchart\Doctrine\Type\DateTimeImmutable\DateTimeImmutableType
			datetime: VasekPurchart\Doctrine\Type\DateTimeImmutable\DateTimeImmutableType
			datetimetz: VasekPurchart\Doctrine\Type\DateTimeImmutable\DateTimeTzImmutableType
		schema_filter: "~^(?!nd_)~" # tables and sequences that start with nd_ are ingored by Doctrine

	functions:
		CAST: App\Doctrine\Postgresql\Functions\Cast

Tweaking

Mapping classes

To create mapping between classes used in annotations and the actually instantiated classes create a Nette extension implementing IClassMappingProvider. Method getClassnameToClassnameMapping is expected to return mapping using class used for annotations as its key and class actually instantiated as the associated value.

Adding entity source directories

To register different source directories for different extensions, let your extension implement IEntitySourceProvider. Method getEntityFolderMappings is expected to return list of folders, where Doctrine entities can be found. Key of the returned array is ignored.

  • v1.0.0 Release v1

    Changes:

    • extended configuration example
    • fixed bug when registering type overrides
    • fixed combination of camelCase and pascal_case in configuration (BC break use type_overrides instead of typeOverrides)
    • removed unnecessary call to registerDoctrineTypeMapping - should be achieved by overriding getMappedDatabaseTypes in the type class (one that extendes Doctrine\DBAL\Types\Type).
  • v0.2.1 Fixed memory leak in CLI or production mode.

    Fixed memory leak in CLI or production mode.

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com