Developed with love by KnpLabs Hire us for your project!
38

KnpPiwikBundle

by KnpLabs

Piwik API client bundle for Symfony2 -- THIS PROJECT IS NO LONGER MAINTAINED by KnpLabs -- Contact us if you want to be the official maintainer of this...

Not actively maintained

This project is not actively maintained by KnpLabs. Please contact us if you would like to take over.

Provides support for Piwik API into your Symfony2 projects.

Installation

Add Knp\PiwikClient to vendors

git submodule add git://github.com/KnpLabs/KnpPiwikClient.git vendor/PiwikClient

Specify Knp\PiwikClient in autoload.php

// app/autoload.php
$loader->registerNamespaces(array(
    // ...
    'Knp\PiwikClient'   => __DIR__.'/../vendor/PiwikClient/src',
    // ...
));

Add Knp\PiwikBundle to your src/Bundle dir

git submodule add git://github.com/KnpLabs/PiwikBundle.git vendor/bundles/Knp/Bundle/PiwikBundle

Add KnpPiwikBundle to your application kernel

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Knp\Bundle\PiwikBundle\KnpPiwikBundle(),
        // ...
    );
}

Configuration

HTTP client (Piwik on remote server)

# app/config/config.yml
knp_piwik:
    connection: piwik.connection.http
    url:        http://piwik.example.com
    token:      PIWIK_API_TOKEN

Don't forget to add Buzz library for HTTP requests into vendors:

git submodule add https://github.com/kriswallsmith/Buzz.git src/vendor/Buzz

And to autoload.php:

// src/autoload.php
$loader->registerNamespaces(array(
    // ...
    'Buzz'  => $vendorDir.'/Buzz/lib',
    // ...
));

Local PHP client (Piwik on local server)

# app/config/config_dev.yml
knp_piwik:
    connection: piwik.connection.piwik
    token:      PIWIK_API_TOKEN

You need to require Piwik library in autoload.php:

// src/autoload.php
// ...
define('PIWIK_ENABLE_DISPATCH', false);
define('PIWIK_ENABLE_ERROR_HANDLER', false);
define('PIWIK_ENABLE_SESSION_START', false);
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
Piwik_FrontController::getInstance()->init();

Testing

There is another connection, called stub. It's used for testing:

# app/config/config_test.yml
knp_piwik:
    connection: piwik.connection.stub

Usage

In your controllers:

$dataArray = $this->get('piwik.client')->
    call('API.getReportMetadata', array('idSites' => array(2, 3)));

Everywhere:

$dataArray = $container->get('piwik.client')->
    call('API.getReportMetadata', array('idSites' => array(2, 3)));

Api Calls

To see all available methods & their parameters, visit Piwik API Reference.

Copyright

PiwikClient Copyright (c) 2011 KnpLabs http://KnpLabs.com. See LICENSE for details.

Copyright (C) 2011 by Knp Labs <http://www.knplabs.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
  • add a note about maintenance of the project
    By Inoryy, 7 months ago
  • Merge pull request #1 from stloyd/composer
    By l3pp4rd, 2 years ago
  • Add composer.json
    By stloyd, 2 years ago
  • Fix url
    By lwagner, 2 years ago
  • Change Knplabs to Knp. BC break before Symfony2 release.
    By mbontemps, 3 years ago
  • Update README
    By Herzult, 3 years ago
  • Move configs merge in a separate method
    By Herzult, 3 years ago
  • Update extension
    By Herzult, 3 years ago
  • Updated README with proper local Piwik integration info
    By everzet, 3 years ago
  • readme update
    By everzet, 3 years ago
  • ns change (PR7 naming convention)
    By everzet, 3 years ago
  • symfony-project.org => symfony.com (PR7 change)
    By everzet, 3 years ago
  • extension class name change (PR7 naming convention)
    By everzet, 3 years ago
  • added stub connection definition
    By everzet, 3 years ago
  • fixed extension
    By everzet, 3 years ago
  • fixed definition & updated README
    By everzet, 3 years ago
  • fixed classname
    By everzet, 3 years ago
  • fixed typo in README
    By everzet, 3 years ago
  • initial commit
    By everzet, 3 years ago