You are on page 1of 2

Creacin de un plugin

Your development environment is set up, and you are now ready to create a
plugin! Creating a plugin consists primarily of creating a couple of files which
can be done by running the following command:
./console generate:plugin --name="MyPlugin"

This will create a new plugin named MyPlugin.


You can use any name for your plugin, but this guide will assume you've
created one named MyPlugin. If you use a different name, make sure to
change MyPlugin to the name you used when copying the code in this guide.
In your browser load Piwik and navigate to Administration > Plugins. Look for
your plugin in the list of plugins, you should see it disabled:

To enable it, either do it through the web interface or use the command line:
./console plugin:activate MyPlugin

Plugin directory structure


The command-line tool will create a new directory for your plugin (in the
plugins sub-directory) and fill it with some files and folders. Here's what these
files and folders are for:

MyPlugin.php:

plugin.json:

README.md:

screenshots/:

Contains your plugin's descriptor class. This class contains


metadata about your plugin and a list of event handlers for Piwik events.
Contains plugin metadata such as the name, description,
version, etc.
A dummy README file for your plugin.

Place screenshots of your plugin in this folder in case you


want to distribute it on the Piwik Marketplace.

What to read next

Ok! You've set up your development environment and created your plugin! Now
all you have to do is make it do what you want. The bad news is that this is the
hard part. The good news is that we've written a bunch of other guides to help
you shorten the learning curve.

If you're interested in creating new analytics reports, you may want


to read about Custom Reports and Visualizing Report Data guides.

If you're interested in changing the look and feel of Piwik, read our
Theming guide.

If you're interested in integrating Piwik with another technology,


you might want to read our Tracking guides to learn how to use our
Tracking API.

If you want to use automated testing to ensure your plugin works,


read your Automated Tests guide.

And make sure to read our security guide, Security in Piwik! We have
very high security standards that your plugin or contribution must respect.
When you've completed your plugin, you can read our Distributing your plugin
guide to learn how to share your plugin with other Piwik users.

You might also like