1. Go to this page and download the library: Download fabiang/doctrine-dynamic library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fabiang / doctrine-dynamic example snippets
use Fabiang\DoctrineDynamic\ConfigurationFactory;
use Fabiang\DoctrineDynamic\ProxyDriverFactory;
use Doctrine\ORM\EntityManager;
$configurationFactory = new ConfigurationFactory();
$configuration = $configurationFactory->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);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.