Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Event system for drop in support of plugin architecture.
Branch: master

Merge pull request #20 from zumba/plugin-event-generator

Plugin context event with generator.
latest commit 5bbfb4da56
@jrbasso jrbasso authored
Failed to load latest commit information.
src Added plugin context to the event object.
tests Added plugin context to the event object.
.gitignore Updated structure to be more composer friendly.
.travis.yml Updated travis to use dev dependency version of PHPUnit. Plugins now have context and work off strategies.
composer.json Corrected website link in composer.
composer.lock Updated lock file for site link change.
phpunit.xml PSR-4 support and flattened directory structure.

Symbiosis is a drop-in event driven plugin architecture.

The goal is to allow anyone to create a plugin structure for their existing code base using an event oriented system. The secondary benefit of using Symbiosis is that the event structure can be used apart from the plugin structure.

Latest Stable Version Build Status


PHP 5.4+


  1. Add as a composer dependency or install directly from composer.
  2. That's it!


  1. Run composer install --dev.
  2. Run phpunit.

Example Plugin



namespace \YourApp\Plugin;

use \Zumba\Symbiosis\Framework\Plugin,

class SamplePlugin extends Plugin implements Registerable {

  public function getEvents() {
    return array(
      'sample.someevent' => function($event) {


Your application bootstrap


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)

Your application


use \Zumba\Symbiosis\Event\Event;

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


    [ping] => pong

Individual Event Registries

As of v1.2, event registries have been added to allow for separation of events. This allows for "namespacing" your event registries. The EventManager remains backwards compatible as now the EventManager creates a static instance of an EventRegistry. Since the event structure is loosly coupled in the Plugin architecture, this allows for namespacing your event registries per plugin.

Example Event Registry namespacing


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

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

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

// Prints:
// Separate registry
// Array(
//   [ping] => pong
// )
Something went wrong with that request. Please try again.