maslosoft / gazebo
Plugin container
Installs: 5 616
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- ext-json: *
- maslosoft/addendum: *
- maslosoft/embedi: *
Requires (Dev)
README
Maslosoft Gazebo
Quick Install
composer require maslosoft/gazebo
Documentation
Plugin container
When developing plugins for Your application, these might come in very different kids. This library helps to manage plugins by providing sets of instantiated plugins required for various scenarios. All plugins for component using gazebo are configured as a one simple list - thus allowing for easy adding and removing them - without bothering which plugin type should go where.
Usage
//Plugins class WaterPlugin implements WetInterface { public $name = 'foo'; } class MetalPlugin implements HardInterface { public $options = false; } class GenericPlugin { } // Config: $config = [ TestModel::class => [ WaterPlugin::class, [ 'class' => MetalPlugin::class, 'options' => true ], GenericPlugin::class, ], ]; // Create plugins but only for selected interfaces $plugins = (new PluginFactory())->instance($this->config, $model, [ HardInterface::class, WetInterface::class ]); var_dump($plugins); // Created flyweight instances of two plugins //array(2) { // [0] => class Maslosoft\GazeboTest\Model\WaterPlugin#181 (1) { // public $name => string(3) "foo" // } // [1] => class Maslosoft\GazeboTest\Model\MetalPlugin#182 (2) { // public $options => bool(true) // public $class => string(38) "Maslosoft\GazeboTest\Model\MetalPlugin" // } //}