common-gateway/t-junction-bundle
Install via Composer (for development):
composer require common-gateway/t-junction-bundle:dev-main
Note: Use dev-main for active development; replace with a stable version tag in production.
Enable the Bundle in config/bundles.php:
return [
// ...
CommonGateway\TJunctionBundle\CommonGatewayTJunctionBundle::class => ['all' => true],
];
First Use Case: Plugin Discovery
common-gateway/pet-store-bundle).php bin/console commongateway:install common-gateway/pet-store-bundle
Verify Installation
config/packages/commongateway.yaml for auto-generated plugin configurations./api/pet-store).Structure a Plugin Bundle:
composer create-project common-gateway/t-junction-bundle my-plugin-bundle
Resources/config/commongateway.yaml (plugin metadata).DependencyInjection/Extension.php (schema/route registration).Controller/ (API endpoints).Register Schemas/Routes:
Extend CommonGateway\TJunctionBundle\DependencyInjection\Extension to define:
# Resources/config/commongateway.yaml
commongateway:
plugins:
my_plugin:
schemas:
- "@MyPluginBundle/Resources/schemas/pet-store.json"
routes:
- { path: "/pets", methods: ["GET"], controller: "MyPluginBundle:Pet:list" }
commongateway:install under the hood).# Install the plugin (downloads + configures)
composer require common-gateway/my-plugin-bundle
php bin/console commongateway:install common-gateway/my-plugin-bundle
# Verify active plugins
php bin/console debug:container | grep commongateway.plugin
Inbound Messages:
The bundle auto-discovers plugin routes and integrates them into Symfony’s router.
Example: A message to /api/pet-store is routed to MyPluginBundle:PetStore:handle.
Outbound Messages:
Use the CommonGateway\Messenger\PluginMessageBus to dispatch messages to plugins:
$bus->dispatch(new PetStoreMessage($data));
Dynamic Config:
Plugin configs are merged into commongateway.yaml at runtime. Override defaults via:
# config/packages/commongateway.yaml
commongateway:
plugins:
my_plugin:
settings:
timeout: 30
Environment-Specific Configs:
Use %kernel.environment% in commongateway.yaml:
commongateway:
plugins:
my_plugin:
debug: "%kernel.debug%"
// src/MessageHandler/PetStoreHandler.php
use CommonGateway\Messenger\PluginMessageBus;
class PetStoreHandler
{
public function __invoke(PetStoreMessage $message, PluginMessageBus $bus)
{
// Process message and reply via $bus->reply()
}
}
# config/api_platform/resources.yaml
resources:
MyPluginBundle\Entity\Pet:
collectionOperations:
get:
method: 'GET'
path: '/pets'
controller: 'MyPluginBundle:Pet:list'
// src/EventListener/PluginInstaller.php
use CommonGateway\TJunctionBundle\Event\PluginInstalledEvent;
class PluginInstaller implements EventSubscriber
{
public static function getSubscribedEvents()
{
return [
PluginInstalledEvent::class => 'onPluginInstalled',
];
}
public function onPluginInstalled(PluginInstalledEvent $event)
{
// Post-install logic (e.g., migrate data)
}
}
Schema Validation Failures:
php bin/console commongateway:validate-schemas common-gateway/my-plugin-bundle
Route Conflicts:
commongateway.yaml:
routes:
- { path: "/my-plugin/pets", ... }
Circular Dependencies:
composer require with --ignore-platform-reqs if needed, or restructure dependencies.Cache Invalidation:
commongateway.yaml require cache clearing:
php bin/console cache:clear
Plugin Isolation:
$container->set('my_plugin.service', MyService::class, PluginScope::class);
Enable Debug Mode:
# config/packages/dev/commongateway.yaml
commongateway:
debug: true
var/log/dev.log.Inspect Active Plugins:
php bin/console debug:container | grep commongateway.plugin.manager
Test Plugin Routes: Use Symfony’s built-in router debugger:
php bin/console debug:router | grep my-plugin
Schema Debugging: Dump loaded schemas:
php bin/console commongateway:debug-schemas
Custom Plugin Installer:
Extend CommonGateway\TJunctionBundle\Installer\PluginInstaller to add pre/post-install hooks.
Dynamic Route Generation:
Override CommonGateway\TJunctionBundle\Router\PluginRouter to modify route generation logic.
Plugin Metadata:
Extend the PluginMetadata class to add custom metadata fields (e.g., version, author).
Messenger Transport: Add a custom transport for plugin-specific messaging:
use CommonGateway\Messenger\Transport\PluginTransport;
Admin UI Customization:
Override Twig templates in Resources/views/ to modify the Plugins tab UI.
Use dev-main for Development:
Avoid stable tags until the plugin is production-ready.
Automate Testing: Test plugin installation in CI with:
php bin/console commongateway:install common-gateway/my-plugin-bundle --env=test
Document Plugin Dependencies:
Clearly list required plugins in composer.json:
"extra": {
"commongateway": {
"requires": ["common-gateway/core-bundle"]
}
}
Leverage Symfony Flex Recipes: Create a recipe for your plugin to simplify installation:
composer create-recipe common-gateway/my-plugin-bundle
How can I help you explore Laravel packages today?