PHP code example of zf3belcebur / doctrine-orm-fast-api

1. Go to this page and download the library: Download zf3belcebur/doctrine-orm-fast-api 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/ */

    

zf3belcebur / doctrine-orm-fast-api example snippets


 [
    return [
        ...other configs
        'ZF3Belcebur\DoctrineORMFastApi' => [
            'route' => [
                'bapi' => [
                    'type' => \Zend\Router\Http\Literal::class,
                    'options' => [
                        'route' => '/my-custom-url',
                    ],
                ],
            ],
        ],
    ];
]


/** @var JsonModel $exchangeMessagesJsonView */
use Zend\View\Model\JsonModel;use ZF3Belcebur\DoctrineORMFastApi\Controller\IndexController;$exchangeMessagesJsonView = $this->forward()->dispatch(IndexController::class, [
    'entity'  => YourEntity::class,
    'options' => [
        'paginator' => true, //set paginator object in return 
        'entityManager' => true, //set entityManager in return
        'hydrate' => false, //set items like objects in return
    ],
]);

  [
     return [
         ...other configs
         'ZF3Belcebur\DoctrineORMFastApi' => [
             'naming_strategy' => DashNamingStrategy::class,
         ],
     ];
 ]
 

 [
    'ZF3Belcebur\DoctrineORMFastApi' => [
        'hydrator-value-strategy-by-type' => [
            'datetime' => \Zend\Hydrator\Strategy\DateTimeFormatterStrategy::class,
        ],
        'hydrator-value-strategy-by-name' => [
            'languages' => \Zend\Hydrator\Strategy\ExplodeStrategy::class,
        ],
       ...other configs
    ]
]

namespace ZF3Belcebur\DoctrineORMFastApi\Resource;


use Doctrine\ORM\EntityManager;
use Zend\Hydrator\HydratorInterface;

interface DoctrineORMFastApiInterface
{
    public function toDoctrineORMFastApi(EntityManager $em,HydratorInterface $hydrator): array;
}


return [
    __NAMESPACE__ => [
        'reflection-file-path' => getcwd() . '/config/autoload/zf3belcebur-doctrine-orm-fast-api.global.php',
        'naming_strategy' => DashNamingStrategy::class,
        'strategies' => [
            EntityStrategy::class => EntityStrategy::class,
            CollectionStrategy::class => CollectionStrategy::class,
        ],
        'reflection-table' => [],
        'hydrator-relation-strategy' => [
            ClassMetadata::MANY_TO_ONE => EntityStrategy::class,
            ClassMetadata::ONE_TO_ONE => EntityStrategy::class,
            ClassMetadata::ONE_TO_MANY => CollectionStrategy::class,
            ClassMetadata::MANY_TO_MANY => CollectionStrategy::class,
        ],
        'hydrator-value-strategy-by-type' => [
            //'datetime' => DateTimeFormatterStrategy::class,
        ],
        'hydrator-value-strategy-by-name' => [
            //'languages' => ExplodeStrategy::class,
            //'defaultLocale' => ExplodeStrategy::class,
        ],
        'hydrator-value-strategy-by-class' => [],
        'route' => [
            __NAMESPACE__ => [
                'type' => Literal::class,
                'options' => [
                    'route' => '/bapi',
                    'defaults' => [
                        'controller' => IndexController::class,
                    ],
                ],
                'may_terminate' => true,
                'child_routes' => [
                    'entity' => [
                        'type' => Segment::class,
                        'options' => [
                            'route' => '/:entity[/:id][/:form]',
                            'constraints' => [
                                'entity' => '[a-zA-Z0-9-]+',
                                'form' => '[a-zA-Z0-9-]+',
                                'id' => '[a-zA-Z0-9-]+',
                            ],
                            'defaults' => [
                                'form' => null,
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
    'controllers' => [
        'factories' => [
            IndexController::class => IndexControllerFactory::class,
        ],
    ],
];