common-gateway/zds-to-zgw-bundle
Understand the Ecosystem Context
Prerequisites
First Use Case: Creating a Basic Plugin
composer create-project common-gateway/zds-to-zgw-bundle my-plugin-bundle.PetStoreBundle references with your bundle name (e.g., MyHealthcareBundle)./api/v1/patients) in src/Controller/ using the provided ZGWBaseController.Installation
composer require common-gateway/my-healthcare-bundle:dev-main
php bin/console commongateway:install common-gateway/my-healthcare-bundle
Plugins.Bundle Structure
src/
Controller/ZGWBaseController.php # Extend this for API routes
Entity/ # Define ZDS/ZGW entities (e.g., Patient, Appointment)
Service/ # Business logic (e.g., PatientService)
Resources/config/ # YAML/XML schemas for ZGW
src/DependencyInjection/: Override services via my_plugin.extension.php.config/packages/: Add Symfony config (e.g., routing, validation).ZGW Integration
Resources/config/.
Example: Map a Patient entity to ZGW’s Zorgaanbieder schema.ZGWBaseController to handle:
ZGWValidator).ZGWResponseFactory).# config/routes.yaml
my_healthcare.api:
resource: "@MyHealthcareBundle/Resources/config/routing.yaml"
type: annotation
ZDS ↔ ZGW Translation
// src/Service/PatientService.php
public function toZGWPatient(ZdsPatient $patient): array {
return [
'zorgaanbieder' => [
'naam' => $patient->getName(),
'bsn' => $patient->getBsn(),
],
];
}
Admin UI Plugin Management
src/Resources/config/plugin.yaml:
name: "My Healthcare Plugin"
description: "Extends ZGW with patient management."
version: "1.0.0"
PatientService).ZGWBaseController and test schema validation with PHPUnit.Psr\Log\LoggerInterface to log ZGW requests/responses.Symfony\Component\Cache).Schema Validation Failures
ZGWValidator in controllers:
$validator = $this->get('zgw_validator');
$errors = $validator->validate($requestData);
if ($errors->count()) { throw new \RuntimeException($errors->get(0)->getMessage()); }
Bundle Auto-Discovery
composer.json has "type": "symfony-bundle".composer dump-autoload after adding the bundle.config/bundles.php includes your bundle.ZGW-Specific Quirks
common-gateway/validation bundle:
$this->get('validator')->validate($patient->getBsn(), new BSN());
X-ZGW-API-Version header. Add middleware:
// src/EventListener/ZGWHeaderListener.php
public function onKernelRequest(GetResponseEvent $event) {
$request = $event->getRequest();
$request->headers->set('X-ZGW-API-Version', '2.0.0');
}
Database Migrations
make:migration).Resources/config/schemas/v1/, v2/, etc.# config/packages/zgw.yaml
zgw:
debug: true # Logs all ZGW requests/responses
tail -f var/log/dev.log | grep "ZGW"
Custom ZGW Profiles
ZGWBaseController to support multiple ZGW profiles (e.g., Zorgaanbieder, Zorgleverancier):
class MyCustomController extends ZGWBaseController {
protected $profile = 'zorgaanbieder';
}
Webhook Integration
WebhookController to handle ZGW webhook callbacks (e.g., for Zorgaanvraag updates):
#[Route('/webhook/zorgaanvraag', name: 'zgw_webhook', methods: ['POST'])]
public function handleWebhook(Request $request): Response {
$payload = json_decode($request->getContent(), true);
// Process webhook...
}
GraphQL Layer
api-platform to expose ZDS data via GraphQL for frontend consumers:
composer require api
Configure in config/packages/api_platform.yaml.Async Processing
symfony/messenger):
$this->get('messenger')->dispatch(new ProcessZGWRequest($data));
How can I help you explore Laravel packages today?