Installation
Add the package via Composer in your Symfony/Laravel project (if using Laravel, wrap it in a Symfony microkernel or use a bridge like symfony/bridge):
composer require common-gateway/kiss-bundle
Enable the Bundle
Register the bundle in your config/bundles.php (Symfony) or equivalent Laravel service provider:
// config/bundles.php
return [
CommonGateway\KissBundle\KissBundle::class => ['all' => true],
];
First Use Case: Plugin Structure
Create a basic plugin structure under src/Kiss/Plugin/ (or your preferred namespace):
src/
├── Kiss/
│ ├── Plugin/
│ │ ├── ExamplePlugin.php
│ │ └── Resources/
│ │ ├── config/
│ │ └── public/
Define a Plugin
Implement the PluginInterface in your plugin class:
namespace Kiss\Plugin;
use CommonGateway\KissBundle\Plugin\PluginInterface;
class ExamplePlugin implements PluginInterface
{
public function getName(): string
{
return 'example_plugin';
}
public function getDescription(): string
{
return 'A demo plugin for KissBundle';
}
}
Register the Plugin
Use the PluginManager to register your plugin in a service or controller:
use CommonGateway\KissBundle\Plugin\PluginManager;
class ExampleController
{
public function __construct(private PluginManager $pluginManager)
{
}
public function index()
{
$plugins = $this->pluginManager->getPlugins();
// Use $plugins...
}
}
PluginInterface and are in a Plugin/ namespace.PluginManager::registerPlugin() for dynamic registration:
$this->pluginManager->registerPlugin(new ExamplePlugin());
config/packages/kiss.yaml:
kiss:
plugins:
enabled: ['example_plugin', 'another_plugin']
disabled: ['deprecated_plugin']
kiss.plugin.registered or kiss.plugin.disabled events:
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use CommonGateway\KissBundle\Event\PluginEvent;
class PluginSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
PluginEvent::REGISTERED => 'onPluginRegistered',
];
}
public function onPluginRegistered(PluginEvent $event)
{
// Handle plugin registration logic
}
}
Plugin/Resources/public/ and use the AssetManager:
$this->assetManager->addPluginAsset('example_plugin', 'css/style.css');
PluginManager to fetch them:
// services.yaml
services:
Kiss\Plugin\ExamplePlugin:
tags: ['kiss.plugin']
Namespace Conflicts
Ensure your plugin classes are in a unique namespace (e.g., App\Plugin\) to avoid collisions with other bundles.
Circular Dependencies Avoid circular dependencies between plugins. Use lazy-loading or dependency injection carefully.
Configuration Overrides
Be cautious when overriding kiss.yaml—changes may affect all plugins globally. Use environment-specific configs (e.g., kiss_dev.yaml) for testing.
Asset Pipeline Issues If assets (CSS/JS) fail to load, verify:
Plugin/Resources/public/.AssetManager is properly configured in your bundle.Plugin Lifecycle
Plugins are initialized when the PluginManager is first called. Avoid heavy initialization logic in the constructor.
Enable Debug Mode
Set KISS_DEBUG=true in your environment to log plugin events and errors:
// .env
KISS_DEBUG=1
Check Registered Plugins Dump the active plugins to verify registration:
dd($this->pluginManager->getPlugins());
Custom Plugin Interfaces
Extend PluginInterface to add methods:
interface CustomPluginInterface extends PluginInterface
{
public function customMethod();
}
Plugin Middleware Use Symfony’s middleware system to intercept plugin calls:
use CommonGateway\KissBundle\Event\PluginEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
$event->getResponse()->headers->set('X-Plugin', $event->getPlugin()->getName());
Database Integration
Store plugin-specific data in a shared database table with a plugin_name column for isolation.
Localization Use Symfony’s translation system with plugin-specific translation domains:
# Plugin/Resources/translations/messages.en.yaml
example_plugin:
greeting: "Hello from %name%!"
Testing
Mock the PluginManager in tests:
$pluginManager = $this->createMock(PluginManager::class);
$pluginManager->method('getPlugin')->willReturn(new ExamplePlugin());
How can I help you explore Laravel packages today?