PHP code example of phpro / zf-apigility-doctrine-bulk
1. Go to this page and download the library: Download phpro/zf-apigility-doctrine-bulk 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/ */
phpro / zf-apigility-doctrine-bulk example snippets
return array(
'modules' => array(
'Phpro\Apigility\Doctrine\Bulk',
// other libs...
),
// Other config
);
return [
// A normal RPC route:
'router' => [
'routes' => [
'api.rpc.bulk' => [
'type' => 'Segment',
'options' => [
'route' => '/api/bulk',
'defaults' => array(
'controller' => 'Api\V1\Rpc\Bulk\BulkController',
'action' => 'bulk',
],
],
],
]
],
/*
* A new bulk controller:
* - entity_class: the classname of the doctrine entity
* - object_manager: the key of the desired object manager in the service manager
* - hydrator: the key of the desired hydrator in the hydrator manager
* - listeners: custom bulk action listeners that are being loaded from the service manager
*/
'zf-apigility' => [
'doctrine-bulk-handlers' => [
'Api\V1\Rpc\Bulk\BulkController' => [
'entity_class' => 'Application\Entity',
'object_manager' => 'doctrine.object-manager.default',
'hydrator' => 'Application\Hydrator\Entity',
'listeners' => [
// Custom ListenerAggregates
],
],
],
],
// Flag the new controller as a RPC controller:
'zf-rpc' => [
'Api\V1\Rpc\Bulk\BulkController' => array(
'http_methods' => array(
0 => 'POST',
),
'route_name' => 'api.rpc.bulk',
'service_name' => 'Bulk',
),
],
// Enable versioning
'zf-versioning' => [
'uri' => [
0 => 'api.rpc.bulk',
],
],
// Add JSON to content negotiation
'zf-content-negotiation' => [
'controllers' => [
'Api\V1\Rpc\Bulk\BulkController' => 'Json',
],
'accept_whitelist' => [
'Api\V1\Rpc\Bulk\BulkController' => array(
0 => 'application/json',
1 => 'application/*+json',
),
],
'content_type_whitelist' => [
'Api\V1\Rpc\Bulk\BulkController' => [
0 => 'application/json',
],
],
],
];
namespace Api\V1\Rpc\Bulk;
use Phpro\Apigility\Doctrine\Bulk\Controller\BulkController as BaseController;
class BulkController extends BaseController
{
}