Installation Run in your Symfony project root:
composer require common-gateway/zgw-stuff-bundle:dev-main
For Dockerized environments:
docker-compose exec php composer require common-gateway/zgw-stuff-bundle:dev-main
Install Schemas as Entities Execute the console command to generate entities from schemas:
php bin/console commongateway:install common-gateway/zgw-stuff-bundle
Or in Docker:
docker-compose exec php bin/console commongateway:install common-gateway/zgw-stuff-bundle
Verify Installation
Check if the bundle is registered in config/bundles.php and clear the cache:
php bin/console cache:clear
Use this bundle as a template to create a custom bundle for ZGW (Zaken Gateway) integration. Start by:
commongateway:install command to auto-generate entities from your schemas.Bundle Creation Workflow
ZGWStuffBundle\Installer\Installer).src/
├── Controller/
├── Entity/
├── Installer/
│ └── Installer.php # Extend to add custom schema logic
├── Resources/
│ ├── config/
│ └── migrations/
└── ZGWStuffBundle.php
Schema-to-Entity Conversion
Installer class to define custom schema mappings:
// src/Installer/CustomInstaller.php
namespace App\Installer;
use CommonGateway\ZGWStuffBundle\Installer\Installer;
class CustomInstaller extends Installer
{
protected function getSchemaFiles(): array
{
return [
__DIR__.'/../Resources/config/schemas/custom_schema.json',
];
}
}
services.yaml:
services:
App\Installer\CustomInstaller:
tags: [zgw.installer]
API Integration
ZGWStuffBundle controller to handle custom API routes:
// src/Controller/CustomController.php
namespace App\Controller;
use CommonGateway\ZGWStuffBundle\Controller\ZGWStuffController;
class CustomController extends ZGWStuffController
{
public function customAction()
{
// Your custom logic
}
}
config/routes.yaml:
app_custom:
resource: "@App\Controller\CustomController"
type: annotation
Event-Driven Extensions
zgw.schema.installed) to trigger post-install logic:
// src/EventListener/CustomListener.php
namespace App\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use CommonGateway\ZGWStuffBundle\Event\SchemaInstalledEvent;
class CustomListener implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
SchemaInstalledEvent::NAME => 'onSchemaInstalled',
];
}
public function onSchemaInstalled(SchemaInstalledEvent $event)
{
// Post-install logic (e.g., seed data, run migrations)
}
}
make:migration command after schema installation to version-control database changes.Installer and ZGWStuffController in PHPUnit tests to isolate bundle logic.config/packages/zgw_stuff.yaml:
zgw_stuff:
default_locale: nl_NL
api_base_url: https://api.example.com
Schema Installation Order
commongateway:install multiple times may cause duplicate entity generation. Use --force cautiously:
php bin/console commongateway:install common-gateway/zgw-stuff-bundle --force
Installer.Entity Naming Conflicts
Installer to customize naming:
protected function getEntityNamespace(): string
{
return 'App\Entity\Custom';
}
Missing Dependencies
composer.json dependencies manually:
"require": {
"symfony/framework-bundle": "^6.0",
"doctrine/orm": "^2.10"
}
Console Command Scope
commongateway:install command is bundle-specific. To avoid conflicts, prefix custom commands:
php bin/console app:install:schemas
Schema Validation Errors
Installer logs for parsing errors:
php bin/console debug:config zgw_stuff | grep -i schema
Entity Generation Issues
php bin/console doctrine:cache:clear-metadata
php bin/console make:entity --regenerate App
Custom Installer Logic
Extend the Installer class to add pre/post-install hooks:
protected function preInstall(): void
{
$this->createBackupDatabase();
}
protected function postInstall(): void
{
$this->runMigrations();
}
Dynamic Schema Loading
Load schemas from external sources (e.g., API) by overriding getSchemaFiles():
protected function getSchemaFiles(): array
{
$schemas = $this->fetchRemoteSchemas();
return array_map(fn($schema) => tempnam(sys_get_temp_dir(), 'zgw_'), $schemas);
}
API Client Customization
Extend the base HTTP client in ZGWStuffController:
protected function createClient(): ClientInterface
{
$client = parent::createClient();
$client->setDefaultOption('auth', 'Bearer ' . $this->getApiToken());
return $client;
}
Event Dispatching Trigger custom events during installation:
$event = new CustomEvent($this->getSchema());
$this->dispatcher->dispatch($event, CustomEvent::NAME);
zgw_stuff as the default config key. Override in config/packages/zgw_stuff.yaml if needed:
zgw_stuff:
prefix: custom_zgw
%env(ZGW_API_KEY)% in config/services.yaml for sensitive data:
parameters:
zgw.api_key: '%env(ZGW_API_KEY)%'
How can I help you explore Laravel packages today?