PHP code example of fabiang / doctrine-dynamic-zf

1. Go to this page and download the library: Download fabiang/doctrine-dynamic-zf 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-zf example snippets


return [
    'modules' => [
        /** **/
        'Fabiang\DoctrineDynamic',
    ],
];



namespace Mymodule;

return [
    /** **/
    'doctrine_dynamic' => [
        \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'
                            ]
                        ]
                    ]
                ]
            ]
        ],
    ]
];