PHP code example of maslosoft / gazebo

1. Go to this page and download the library: Download maslosoft/gazebo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maslosoft / gazebo example snippets


//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"
//	}
//}