Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabiang/doctrine-dynamic
Load Doctrine mappings dynamically for your entities by configuration
https://github.com/fabiang/doctrine-dynamic
doctrine doctrine-extension orm php
Last synced: 21 days ago
JSON representation
Load Doctrine mappings dynamically for your entities by configuration
- Host: GitHub
- URL: https://github.com/fabiang/doctrine-dynamic
- Owner: fabiang
- License: other
- Created: 2015-10-19T17:35:20.000Z (about 9 years ago)
- Default Branch: develop
- Last Pushed: 2022-05-13T11:14:01.000Z (over 2 years ago)
- Last Synced: 2024-09-14T05:53:02.613Z (2 months ago)
- Topics: doctrine, doctrine-extension, orm, php
- Language: PHP
- Homepage:
- Size: 88.9 KB
- Stars: 7
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# fabiang/doctrine-dynamic
Proxy Driver for [Doctrine](http://doctrine-project.org/) which allows you to add
custom relations dynamically by configuration.This is useful if you use foreign entities, which you can't change, but you like
to add own relations between them and your entities.[![Latest Stable Version](https://poser.pugx.org/fabiang/doctrine-dynamic/version)](https://packagist.org/packages/fabiang/doctrine-dynamic)
[![License](https://poser.pugx.org/fabiang/doctrine-dynamic/license)](https://packagist.org/packages/fabiang/doctrine-dynamic)
[![Unit Tests](https://github.com/fabiang/doctrine-dynamic/actions/workflows/unit.yml/badge.svg)](https://github.com/fabiang/doctrine-dynamic/actions/workflows/unit.yml)
[![Integration Tests](https://github.com/fabiang/doctrine-dynamic/actions/workflows/behat.yml/badge.svg)](https://github.com/fabiang/doctrine-dynamic/actions/workflows/behat.yml)
[![Static Code Analysis](https://github.com/fabiang/doctrine-dynamic/actions/workflows/static.yml/badge.svg)](https://github.com/fabiang/doctrine-dynamic/actions/workflows/static.yml)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/fabiang/doctrine-dynamic/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/fabiang/doctrine-dynamic/?branch=main)
[![Code Coverage](https://scrutinizer-ci.com/g/fabiang/doctrine-dynamic/badges/coverage.png?b=main)](https://scrutinizer-ci.com/g/fabiang/doctrine-dynamic/?branch=main)## Features
* Setting all possible relations to entities:
* OneToOne
* ManyToOne
* OneToMany
* ManyToMany
* Setting repository class## Installation
New to Composer? Read the [introduction](https://getcomposer.org/doc/00-intro.md#introduction). Run the following Composer command:
```console
$ composer require fabiang/doctrine-dynamic
```## Framework integration
* [Laminas](https://github.com/fabiang/doctrine-dynamic-laminas)
## Usage
```php
factory([
\Mymodule\Entity\Customer::class => [
'options' => [
'repository' => \Mymodule\Repository\CustomerRepository::class,
],
'fields' => [
'fieldname' => [
'products' => [
'oneToMany' => [
[
'targetEntity' => \Mymodule\Entity\Customer::class,
'mappedBy' => 'customer',
],
]
],
]
]
],
\Mymodule\Entity\Products::class => [
'fields' => [
'customer' => [
'manyToOne' => [
[
'targetEntity' => \Mymodule\Entity\Products::class,
'inversedBy' => 'products',
'joinColumns' => [
'name' => 'customer_id',
'referencedColumnName' => 'id'
]
],
]
],
]
],
]);/** @var $entityManager EntityManager */
// get it from a container for example
$entityManager = $container->get(EntityManager::class);$proxyDriverFactory = new ProxyDriverFactory();
$proxyDriverFactory->factory($entityManager, $configuration);
```## Development
This library is tested with [PHPUnit](https://phpunit.de/) and [Behat](http://behat.org/).
Fork the project on Github and send an pull request with your changes.
Make sure you didn't break anything with running the following commands:```console
composer install
./vendor/bin/phpunit
./vendor/bin/behat
```## Licence
BSD-2-Clause. See the [LICENSE.md](LICENSE.md).