Skip to content

Instantly share code, notes, and snippets.

@cjsaylor
Created August 21, 2012 11:16
Show Gist options
  • Save cjsaylor/3414629 to your computer and use it in GitHub Desktop.
Save cjsaylor/3414629 to your computer and use it in GitHub Desktop.
Example use of Symbiosis
<?php
use \Zumba\Symbiosis\Plugin\PluginManager;
// Somewhere in your application bootstrap, load your plugins
PluginManager::loadPlugins(
'/path/to/your/plugin/directory', // Path to where you stored your plugins
'YourApp\Plugin' // namespace defined in your plugins (see example above)
);
<?php
namespace \YourApp\Plugin;
use \Zumba\Symbiosis\Framework\Plugin,
\Zumba\Symbiosis\Event\EventManager;
class SamplePlugin extends Plugin {
public function registerEvents() {
EventManager::register('sample.someevent', function($event) {
print_r($event->data());
});
}
}
<?php
use \Zumba\Symbiosis\Event\Event;
// Somewhere in your app, trigger plugins listening to event
$event = new Event('sample.someevent', array('ping' => 'pong'));
$event->trigger();
Array
(
[ping] => pong
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment