dev-master
9999999-dev http://github.com/KnpLabs/KnpPiwikBundlePiwik API client bundle for Symfony2.
MIT
The Requires
by KnpLabs Team
analytics bundle knplabs piwik knp
Piwik API client bundle for Symfony2.
Provides support for Piwik API into your Symfony2 projects., (*1)
git submodule add git://github.com/KnpLabs/KnpPiwikClient.git vendor/PiwikClient
// app/autoload.php $loader->registerNamespaces(array( // ... 'Knp\PiwikClient' => __DIR__.'/../vendor/PiwikClient/src', // ... ));
git submodule add git://github.com/KnpLabs/PiwikBundle.git vendor/bundles/Knp/Bundle/PiwikBundle
// app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Knp\Bundle\PiwikBundle\KnpPiwikBundle(), // ... ); }
# 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:, (*2)
git submodule add https://github.com/kriswallsmith/Buzz.git src/vendor/Buzz
And to autoload.php:, (*3)
// src/autoload.php $loader->registerNamespaces(array( // ... 'Buzz' => $vendorDir.'/Buzz/lib', // ... ));
# app/config/config_dev.yml knp_piwik: connection: piwik.connection.piwik token: PIWIK_API_TOKEN
You need to require Piwik library in autoload.php:, (*4)
// 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();
There is another connection, called stub. It's used for testing:, (*5)
# app/config/config_test.yml knp_piwik: connection: piwik.connection.stub
In your controllers:, (*6)
$dataArray = $this->get('piwik.client')-> call('API.getReportMetadata', array('idSites' => array(2, 3)));
Everywhere:, (*7)
$dataArray = $container->get('piwik.client')-> call('API.getReportMetadata', array('idSites' => array(2, 3)));
To see all available methods & their parameters, visit Piwik API Reference., (*8)
PiwikClient Copyright (c) 2011 KnpLabs http://KnpLabs.com. See LICENSE for details., (*9)
Piwik API client bundle for Symfony2.
MIT
analytics bundle knplabs piwik knp