common-gateway/xxllnc-to-ktb-bundle
Understand the Purpose: This bundle is a template for creating Symfony Flex bundles as plugins for the Common Gateway ecosystem. It’s not a standalone utility but a scaffold for extending Gateway functionality.
Prerequisites:
First Use Case:
XxllncToKtbBundle with your bundle name (e.g., MyCustomGatewayBundle).composer.json, README.md, and bundle class annotations).Installation:
composer require common-gateway/xxllnc-to-ktb-bundle:dev-main
php bin/console commongateway:install common-gateway/xxllnc-to-ktb-bundle
Where to Look First:
src/DependencyInjection/ → Bundle configuration and extensions.Resources/config/ → YAML/XML services and routes.README.md → Example workflows for plugin development.composer.json → Flex recipe and dependencies.XxllncToKtb references with your bundle’s namespace (e.g., MyCompany\MyPluginBundle).src/
├── DependencyInjection/ # Configuration, extensions
│ ├── MyPluginExtension.php # Override `load()` to add services/routes
│ └── MyPluginExtension.php.dist
├── Resources/config/ # Services, routes, doctrine mappings
│ ├── services.yaml
│ └── routes.yaml
└── MyPluginBundle.php # Bundle class (annotate with `@Bundle`)
MyPluginBundle.php: Annotate with @Bundle and define dependencies (e.g., CommonGatewayCoreBundle).MyPluginExtension.php: Extend Symfony’s ExtensionInterface to load services/routes dynamically.services.yaml: Define services (e.g., command buses, repositories) with tags like commongateway.command_handler.Plugins tab. Ensure:
composer.json includes a flex recipe (copy from this template).CommonGateway\Plugin\PluginInterface (if extending functionality).autoconfigure: true in services.yaml for auto-wiring.@tag {name: commongateway.command_handler}).src/Command/ and tag them with console.command.# services.yaml
services:
MyPlugin\Command\MyCommand:
tags: ['console.command']
arguments: ['@my_plugin.service']
Resources/config/doctrine/ to extend Common Gateway’s database schema.# Resources/config/doctrine/MyEntity.orm.yml
MyPlugin\Entity\MyEntity:
type: entity
table: my_plugin_entity
fields:
id: ~
name: { type: string }
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
src/EventListener/ and tagging them:
services:
MyPlugin\EventListener\MyListener:
tags:
- { name: kernel.event_listener, event: commongateway.my_event, method: onMyEvent }
composer.json extra.flex section to define your plugin’s requirements:
"extra": {
"flex": {
"common-gateway/bundle": {
"type": "symfony-bundle",
"replaces": {
"common-gateway/core": "*"
}
}
}
}
composer require my-vendor/my-plugin-bundle:dev-main
Debugging Bundle Loading:
php bin/console debug:container MyPluginBundle to verify services are loaded.var/log/dev.log for DI errors.Testing Plugins:
// tests/PluginTest.php
$kernel = new Kernel('test', false);
$kernel->boot();
$container = $kernel->getContainer();
Versioning:
composer.json version.dev-main for active development, 1.0.0 for stable releases.Documentation:
README.md with:
config/packages/my_plugin.yaml).my:command, run php bin/console my:command").Bundle Auto-Discovery:
Plugins tab.composer.json has a type: symfony-bundle.config/bundles.php (Symfony 5.1+).MyPluginBundle vs. My_Plugin_Bundle).Circular Dependencies:
MyPluginExtension fails to load due to missing dependencies.CommonGatewayCoreBundle in composer.json:
"require": {
"common-gateway/core": "^1.0"
}
parent::load() in MyPluginExtension to inherit core configurations.Schema Conflicts:
my_plugin_*).doctrine:migrations:dump-schema to inspect the schema before applying.Console Command Not Found:
php bin/console my:command returns "command not found".src/Command/ and tagged in services.yaml.php bin/console cache:clear
Flex Recipe Not Triggering:
composer require doesn’t install the plugin via Flex.extra.flex section in composer.json is correctly formatted.Enable Debug Mode:
APP_ENV=dev APP_DEBUG=1 php bin/console debug:container
MyPluginBundle.Log Configuration:
MyPluginExtension::load():
$container->get('logger')->info('MyPluginExtension loaded', ['config' => $configs]);
Check Event Dispatcher:
// src/EventListener/DebugListener.php
public function onKernelRequest(GetResponseEvent $event) {
error_log('MyPlugin: Kernel request received');
}
CommonGateway\Plugin\PluginInterface to add metadata (e.g., name, version, description) for the admin UI:
class MyPluginBundle extends Bundle implements PluginInterface {
public function getPluginMetadata(): array {
return [
'name' => 'My Awesome Plugin',
'version' => '1.0.0',
'description' => 'Extends Gateway with XYZ features.',
How can I help you explore Laravel packages today?