fgsl / doctrine-orm-module
Laminas Module that provides Doctrine ORM functionality
                                    Fund package maintenance!
                                                                            
                                                                                                                                        Patreon
                                                                                    
                                                                            
                                                                                                                                        Tidelift
                                                                                    
                                                                            
                                                                                                                                        www.doctrine-project.org/sponsorship.html
                                                                                    
                                                                
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/fgsl/doctrine-orm-module
Requires
- php: ^7.1
- doctrine/dbal: ^2.6.0
- doctrine/doctrine-module: ^3.0.1
- doctrine/orm: ^2.6.3
- laminas/laminas-hydrator: ^3.0.0
- laminas/laminas-mvc: ^3.1
- laminas/laminas-servicemanager: ^3.3
- laminas/laminas-stdlib: ^3.2.1
- symfony/console: ^3.3 || ^4.0 || ^5.0
Requires (Dev)
- doctrine/data-fixtures: ^1.2.1
- doctrine/migrations: ^1.5 || ^2.0
- laminas/laminas-console: ^2.6
- laminas/laminas-developer-tools: ^1.1
- laminas/laminas-i18n: ^2.7.3
- laminas/laminas-log: ^2.9
- laminas/laminas-modulemanager: ^2.7.2
- laminas/laminas-mvc-console: ^1.2
- laminas/laminas-serializer: ^2.8
- phpunit/phpunit: ^7.0.3
- squizlabs/php_codesniffer: ^2.7
Suggests
- doctrine/migrations: doctrine migrations if you want to keep your schema definitions versioned
- laminas/laminas-developer-tools: laminas-developer-tools if you want to profile operations executed by the ORM during development
- laminas/laminas-form: if you want to use form elements backed by Doctrine
This package is auto-updated.
Last update: 2025-10-08 06:12:27 UTC
README
This is a refactoring of Doctrine\DoctrineORMModule for Laminas.
DoctrineORMModule integrates Doctrine 2 ORM with Laminas quickly and easily.
- Doctrine 2 ORM support
- Multiple ORM entity managers
- Multiple DBAL connections
- Reuse existing PDO connections in DBAL connection
Installation
Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.
composer require fgsl/doctrine-orm-module
Then add DoctrineModule and DoctrineORMModule to your config/application.config.php and create directory
data/DoctrineORMModule/Proxy and make sure your application has write access to it.
Installation without composer is not officially supported and requires you to manually install all dependencies
that are listed in composer.json
Entities settings
To register your entities with the ORM, add following metadata driver configurations to your module (merged) configuration for each of your entities namespaces:
<?php return [ 'doctrine' => [ 'driver' => [ // defines an annotation driver with two paths, and names it `my_annotation_driver` 'my_annotation_driver' => [ 'class' => \Doctrine\ORM\Mapping\Driver\AnnotationDriver::class, 'cache' => 'array', 'paths' => [ 'path/to/my/entities', 'another/path', ], ], // default metadata driver, aggregates all other drivers into a single one. // Override `orm_default` only if you know what you're doing 'orm_default' => [ 'drivers' => [ // register `my_annotation_driver` for any entity under namespace `My\Namespace` 'My\Namespace' => 'my_annotation_driver', ], ], ], ], ];
Connection settings
Connection parameters can be defined in the application configuration:
<?php return [ 'doctrine' => [ 'connection' => [ // default connection name 'orm_default' => [ 'driverClass' => \Doctrine\DBAL\Driver\PDOMySql\Driver::class, 'params' => [ 'host' => 'localhost', 'port' => '3306', 'user' => 'username', 'password' => 'password', 'dbname' => 'database', ], ], ], ], ];
Full configuration options
An exhaustive list of configuration options can be found directly in the Options classes of each module.
You can find documentation about the module's features at the following links:
Registered Service names
- doctrine.connection.orm_default: a- Doctrine\DBAL\Connectioninstance
- doctrine.configuration.orm_default: a- Doctrine\ORM\Configurationinstance
- doctrine.driver.orm_default: default mapping driver instance
- doctrine.entitymanager.orm_default: the- Doctrine\ORM\EntityManagerinstance
- Doctrine\ORM\EntityManager: an alias of- doctrine.entitymanager.orm_default
- doctrine.eventmanager.orm_default: the- Doctrine\Common\EventManagerinstance
Command Line
Access the Doctrine command line as following
./vendor/bin/doctrine-module
Service Locator
To access the entity manager, use the main service locator:
// for example, in a controller: $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $em = $this->getServiceLocator()->get(\Doctrine\ORM\EntityManager::class);