Creating a CakePHP Plugin using Symbiosis

I had created a cake component for Askimet ( before and I wanted to check how easy would it be to create a plugin using the Symbiosis project (

After cloning the CakePHP project, I have cloned the Symbiosis project into the app/Vendor folder. Right now I had the 2 elements necessary to make it work.

Most of the process is done just like it is explained on the GitHub page from the Symbiosis project, but here are the caveats that can be easily fixed. The 2 big caveats are on both the bootstrap and on the Plugin class. I’m describing them bellow.

CakePHP Bootstrap

  • include the autoloader
  • use the \Zumba\Autoloader::register($namespcae, $pathToNamespace) to register your namespace class.
  • include the Zumba\Symbiosis\Log in the same way you will include the symbiosis plugin manager
  • include the Zumba\Symbiosis\Plugin\PluginManager
  • Use the Log receive function (Log::receive($message, $level, $data)) to wrap to a CakeLog – in another words, whenever the Symbiosis logs something it will save on the default CakeLog.
  • Load the Plugins

This should be all you should do for the bootstrap, and it is really 99% of the configuration job. The biggest caveat is to register your namespace class. Without it, nothing really loads and you are left in blank.
The best way to know if you have a configuration problem is to use the PluginManager::getPLuginList(); This will return all loaded plugins and your newly created plugin should be in that list, otherwise, considering that you have followed the tutorial from github, you most likely have a configuration issue.

The Askimet Class

The Class will be pretty simple and it follows the structure that is suggested on the GitHub page from Symbiosis. The method registerEvents will have every function handled as a “triggable” event, but when you call the event from, for example, your controller, the $event->trigger() will only return true or false. Is important to keep this in mind because if your plugin needs to modify and handle some sort of data, you will need to call, inside the event trigger, another function that will handle the return of the data.

In Short

In short considering the time that I took to:

  • clone CakePHP project
  • clone Symbiosis project into the Vendor folder
  • create the new plugin on the Plugin folder (re-using the methods that I had from the component with some small tweaks)
  • configuring the application to use Symbiosis

All together it took me about 1 hour to do it all and most of the time was taken because I had misconfigurations that wasn’t making my plugin to load properly, otherwise, the whole creation process wouldn’t take more than 15 minutes.


About mcloide

Making things simpler, just check: View all posts by mcloide

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: