Piwik

# open source web analytics

http://piwik.org/

Les articles publiés sur le site

  • Introducing CI Status : the build dashboard for Travis CI

    6 octobre 2014, par Matthieu NapoliDevelopment, Meta

    The Piwik team has been working on a new tool for developers: CI Status.

    CI Status is a dashboard displaying the latest build status for all your repositories set up on Travis-CI.org or Travis-CI.com. The usage is meant to be as simple as possible: just login using your GitHub account and enjoy.

    CI-status.com

    Give CI Status a try now at ci-status.com!

    CI Status screenshot

    On your server: Setup CI Status

    The application is open source (released under the GNU Affero General Public License) and developed on GitHub. You are encouraged to contribute to the GitHub project if you find any bug or if you want to add new features. Since it was developed with reusability in mind, you can also install and maintain the application on your own server.

    We hope you will find this tool as useful as we do!

  • Introducing CI Status : the build dashboard for Travis CI

    6 octobre 2014, par Matthieu NapoliDevelopment, Meta

    The Piwik team has been working on a new tool for developers: CI Status.

    CI Status is a dashboard displaying the latest build status for all your repositories set up on Travis-CI.org or Travis-CI.com. The usage is meant to be as simple as possible: just login using your GitHub account and enjoy.

    CI-status.com

    Give CI Status a try now at ci-status.com!

    CI Status screenshot

    On your server: Setup CI Status

    The application is open source (released under the GNU Affero General Public License) and developed on GitHub. You are encouraged to contribute to the GitHub project if you find any bug or if you want to add new features. Since it was developed with reusability in mind, you can also install and maintain the application on your own server.

    We hope you will find this tool as useful as we do!

  • Piwik Mobile 2.1.1 with full support for iOS 8 and iPhone 6 Plus

    2 octobre 2014, par Thomas SteurPiwik Mobile Releases

    Piwik Mobile 2.1.1 is now available and comes with full support for iOS 8 and iPhone 6 Plus.

    Please email us if you still experience any issues with this release.

    Thank you!

  • Piwik Mobile 2.1.1 with full support for iOS 8 and iPhone 6 Plus

    2 octobre 2014, par Thomas SteurPiwik Mobile Releases

    Piwik Mobile 2.1.1 is now available and comes with full support for iOS 8 and iPhone 6 Plus.

    Please email us if you still experience any issues with this release.

    Thank you!

  • How to create a command – Introducing the Piwik Platform

    2 octobre 2014, par Thomas SteurDevelopment

    This is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to publish your plugin or theme on the Piwik Marketplace). This time you’ll learn how to create a new command. For this tutorial you will need to have basic knowledge of PHP.

    What is a command?

    A command can execute any task on the command line. Piwik provides currently about 50 commands via the Piwik Console. These commands let you start the archiver, change the number of available custom variables, enable the developer mode, clear caches, run tests and more. You could write your own command to sync users or websites with another system for instance.

    Getting started

    In this series of posts, we assume that you have already set up your development environment. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik.

    To summarize the things you have to do to get setup:

    • Install Piwik (for instance via git).
    • Activate the developer mode: ./console development:enable --full.
    • Generate a plugin: ./console generate:plugin --name="MyCommandPlugin". There should now be a folder plugins/MyCommandPlugin.
    • And activate the created plugin under Settings => Plugins.

    Let’s start creating a command

    We start by using the Piwik Console to create a new command. As you can see there is even a command that lets you easily create a new command:

    ./console generate:command

    The command will ask you to enter the name of the plugin the created command should belong to. I will simply use the above chosen plugin name “MyCommandPlugin”. It will ask you for a command name as well. I will use “SyncUsers” in this example. There should now be a file plugins/MyCommandPlugin/Commands/Syncusers.php which contains already an example to get you started easily:

    class Syncusers extends ConsoleCommand
    {
        protected function configure()
        {
            $this->setName('mycommandplugin:syncusers');
            $this->setDescription('MyCommandPlugin');
            $this->addOption('name', null, InputOption::VALUE_REQUIRED, 'Your name:');
        }
    
        /**
         * Execute command like: ./console mycommandplugin:syncusers --name="The Piwik Team"
         */
        protected function execute(InputInterface $input, OutputInterface $output)
        {
            $name    = $input->getOption('name');
    
            $message = sprintf('Syncusers: %s', $name);
    
            $output->writeln($message);
        }
    }

    Any command that is placed in the “Commands” folder of your plugin will be available on the command line automatically. Therefore, the newly created command can now be executed via ./console mycommandplugin:syncusers --name="The Piwik Team".

    The code template explained

    protected function configure()
    {
        $this->setName('mycommandplugin:checkdatabase');
        $this->setDescription('MyCommandPlugin');
        $this->addOption('name', null, InputOption::VALUE_REQUIRED, 'Your name:');
    }

    As the name says the method configure lets you configure your command. You can define the name and description of your command as well as all the options and arguments you expect when executing it.

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $name    = $input->getOption('name');
        $message = sprintf('Syncusers: %s', $name);
        $output->writeln($message);
    }
    

    The actual task is defined in the execute method. There you can access any option or argument that was defined on the command line via $input and write anything to the console via $output argument.

    In case anything went wrong during the execution you should throw an exception to make sure the user will get a useful error message. Throwing an exception when an error occurs will make sure the command does exit with a status code different than 0 which can sometimes be important.

    Advanced features

    The Piwik Console is based on the powerful Symfony Console component. For instance you can ask a user for any interactive input, you can use different output color schemes and much more. If you are interested in learning more all those features have a look at the Symfony console website.

    How to test a command

    After you have created a command you are surely wondering how to test it. Ideally, the actual command is quite short as it acts like a controller. It should only receive the input values, execute the task by calling a method of another class and output any useful information. This allows you to easily create a unit or integration test for the classes behind the command. We will cover this topic in one of our future blog posts. Just one hint: You can use another command ./console generate:test to create a test. If you want to know how to test a command have a look at the Testing Commands documentation.

    Publishing your Plugin on the Marketplace

    In case you want to share your commands with other Piwik users you can do this by pushing your plugin to a public GitHub repository and creating a tag. Easy as that. Read more about how to distribute a plugin and best practices when publishing a plugin.

    Isn’t it easy to create a command? We never even created a file! If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.