PHP code example of zumba / symbiosis

1. Go to this page and download the library: Download zumba/symbiosis 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/ */

    

zumba / symbiosis example snippets




namespace \YourApp\Plugin;

use \Zumba\Symbiosis\Framework\Plugin,
    \Zumba\Symbiosis\Event\EventManager,
    \Zumba\Symbiosis\Framework\Registerable;

class SamplePlugin extends Plugin implements Registerable
{
  public function getEvents()
  {
    return [
      'sample.someevent' => function($event) {
        print_r($event->data());
      });
    ];
  }

}



use \Zumba\Symbiosis\Plugin\PluginManager;

// Somewhere in your application bootstrap, load your plugins
$pluginManager = new PluginManager(
  '/path/to/your/plugin/directory', // Path to where you stored your plugins
  'YourApp\Plugin'                  // namespace defined in your plugins (see example above)
);
$pluginManager->loadPlugins();



use \Zumba\Symbiosis\Event\Event;

// Somewhere in your app, trigger plugins listening to event
$pluginManager->trigger(new Event('sample.someevent', ['ping' => 'pong']));




$registry1 = new \Zumba\Symbiosis\Event\EventRegistry();
$registry2 = new \Zumba\Symbiosis\Event\EventRegistry();

$registry1->register('sample.someevent', function ($event) {
	print_r($event->data());
});
$registry2->register('sample.someevent', function ($event) {
	echo "Separate registry\n";
	print_r($event->data());
});

$event = new \Zumba\Symbiosis\Event\Event('sample.someevent', array('ping' => 'pong'));
$registry1->dispatch($event);
// Prints:
// Array(
//   [ping] => pong
// )

$registry2->dispatch($event);
// Prints:
// Separate registry
// Array(
//   [ping] => pong
// )