gordinskiy / doctrine-fluent-mappin-bundle
Symfony Bundle for Fluent Mapping Driver from laravel-doctrine
Requires
- laravel-doctrine/fluent: ^1.3
- symfony/framework-bundle: ^6.0
Requires (Dev)
- php: ^8.1
- phpunit/phpunit: ^10.1
- symfony/phpunit-bridge: ^6.2
This package is auto-updated.
Last update: 2024-10-18 00:43:28 UTC
README
Symfony Bundle for laravel-doctrine/fluent
that provide alternative PHP Mapping Driver for Doctrine ORM.
Works as extension for doctrine/DoctrineBundle.
How It Works
Doctrine provides the ability to implement your own mapping driver
(Documentation).
Fluent Mapping Driver - Doctrine mapping driver implementation from authors of
laravel-doctrine/orm
(Documentation).
allows you to manage your mappings in an Object Oriented approach, separating your entities from your mapping configuration without the need for configuration files like XML or YAML.
Despite the vendor name, this package does not contain any dependency on Laravel framework or its components.
DoctrineBundle - Symfony bundle that provides integration of Doctrine projects with Symfony framework (Documentation).
DoctrineFluentMappingBundle configures Fluent Mapping Driver and registers it as default mapping driver for DoctrineBundle by replacing definition of doctrine.orm.default_metadata_driver.
Installation
Run this command in your terminal:
composer require gordinskiy/doctrine-fluent-mapping-bundle
If you don't use Symfony Flex, you must enable the bundle manually in the application:
// config/bundles.php return [ ... Gordinskiy\DoctrineFluentMappingBundle\DoctrineFluentMappingBundle::class => ['all' => true], ];
Configuration
Create config/packages/doctrine_fluent.yaml
file and list your entity mappings in it:
doctrine_fluent: mappings: - Infrastructure\Doctrine\Mappings\UserMapping - Infrastructure\Doctrine\Mappings\RoleMapping - Infrastructure\Doctrine\Mappings\AccountMapping
Configure by directories list
You can also configure mappings by directories list:
doctrine_fluent: mappings_paths: - src/Context/Infrastructure/Doctrine/Mappings - src/SomeAnotherContext/Infrastructure/Doctrine/Mappings - src/ActivityLog/Infrastructure/Doctrine/Mappings - src/OneMoreContext/Infrastructure/Doctrine/Mappings
You can use absolute paths or paths relative to the project root directory.
All classes in these directories that implement Mapping interface will be automatically registered as mappings.