Giter Club home page Giter Club logo

knppiwikbundle's Introduction

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.

knppiwikbundle's People

Contributors

everzet avatar herzult avatar l3pp4rd avatar stloyd avatar mbontemps avatar inoryy avatar lwagner avatar

Watchers

Daniel Holzmann avatar James Cloos avatar CodeLovers avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.