PHPackages                             devhelp/piwik-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. devhelp/piwik-bundle

ActiveSymfony-bundle[API Development](/categories/api)

devhelp/piwik-bundle
====================

integration of devhelp/piwik-api into symfony. Allows to create services for piwik api methods

1.1(8y ago)626.5k1MITPHPPHP &gt;=5.4

Since Apr 25Pushed 8y ago4 watchersCompare

[ Source](https://github.com/devhelp/piwik-bundle)[ Packagist](https://packagist.org/packages/devhelp/piwik-bundle)[ Docs](http://devhelp.pl)[ RSS](/packages/devhelp-piwik-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (8)Used By (0)

[![Build Status](https://camo.githubusercontent.com/bc872558fd0d30eafaf6457530b2799d29c95ea8be4d96feb7d719cf71657750/68747470733a2f2f7472617669732d63692e6f72672f64657668656c702f706977696b2d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/devhelp/piwik-bundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0d221cd2730b8be6aa477dcd1a864119801b8e5410a65d83a11cd51895dd5462/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64657668656c702f706977696b2d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/devhelp/piwik-bundle?branch=master)

Purpose
-------

[](#purpose)

Bundle provides integration with [Piwik API](http://developer.piwik.org/api-reference/reporting-api). Adds services to the dependency injection container that allows to use Piwik API methods as services. It uses [devhelp/piwik-api](http://github.com/devhelp/piwik-api) library - check its documentation for more advanced usage.

Installation
------------

[](#installation)

```
$ composer require devhelp/piwik-bundle

```

For more information please check [composer website](http://getcomposer.org).

Add the bundle to `AppKernel`

```
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            //...
            new \Devhelp\PiwikBundle\DevhelpPiwikBundle(),
            //...
        );

        //...

        return $bundles;
    }

    //...
}
```

### Sandbox

[](#sandbox)

Full working example can be found at [devhelp/piwik-bundle-sandbox](http://github.com/devhelp/piwik-bundle-sandbox)

Usage
-----

[](#usage)

### Define API connection in config.yml

[](#define-api-connection-in-configyml)

```
devhelp_piwik:
    client: my_piwik.client
    api:
        reader:
            url: http://my_piwik_instance.piwik.pro
            default_params:
                token_auth: %piwik_token_auth%
                idSite: %piwik_site_id%
```

### Create piwik client service that is used in config.yml

[](#create-piwik-client-service-that-is-used-in-configyml)

This example uses `PiwikGuzzleClient` class that is responsible for making http request to [Piwik](http://piwik.org). You can include this extension by including [devhelp/piwik-api-guzzle](http://github.com/devhelp/piwik-api-guzzle) in your project

```
my_piwik.client:
    class: Devhelp\Piwik\Api\Guzzle\Client\PiwikGuzzleClient
    arguments:
        # guzzle service must implement GuzzleHttp\ClientInterface
        - '@guzzle'
```

### Use API method in your use case

[](#use-api-method-in-your-use-case)

service configuration

```
my_service:
    class: Acme\DemoBundle\Service\MyService
    arguments:
        # it is an alias of first configured api (in this case it equals devhelp_piwik.api.reader service)
        - '@devhelp_piwik.api'
```

service definition

```
namespace Acme\DemoBundle\Service;

use Devhelp\Piwik\Api\Api;

class MyService
{

    /**
     * @var Api
     */
    private $piwikApi;

    public function __construct(Api $piwikApi)
    {
        $this->piwikApi = $piwikApi;
    }

    public function doSomething()
    {
        //...
        $this->piwikApi->getMethod('PiwikPlugin.pluginAction')->call();
        //...
    }
}
```

### Define API parameters resolved at runtime

[](#define-api-parameters-resolved-at-runtime)

You are allowed to set services as a params. If you do that then the service will be used to resolve the parameter at runtime. For example have a service that would return `token_auth` of logged in user

```
devhelp_piwik:
    client: my_piwik.client
    api:
        reader:
            url: http://my_piwik_instance.piwik.pro
            default_params:
                token_auth: my_token_auth_provider
                idSite: %piwik_site_id%
```

`my_token_auth_provider` service definition

```
my_token_auth_provider:
    class: Acme\DemoBundle\Param\MyTokenAuthProvider
    arguments:
        - '@security.token_storage'
```

`MyTokenAuthProvider` class definition (assumes that User class has getPiwikToken method)

```
namespace Acme\DemoBundle\Param;

use Devhelp\Piwik\Api\Param\Param;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;

class MyTokenAuthProvider implements Param
{

    /**
     * @var TokenStorageInterface
     */
    private $tokenStorage;

    public function __construct(TokenStorageInterface $tokenStorage)
    {
        $this->tokenStorage = $tokenStorage;
    }

    public function value()
    {
        $token = $this->tokenStorage->getToken();

        return $token instanceof TokenInterface ? $token->getUser()->getPiwikToken() : null;
    }
}
```

### Define API methods as services

[](#define-api-methods-as-services)

```
my_piwik_method:
    class: Devhelp\Piwik\Api\Method\Method
    factory:
        - '@devhelp_piwik.api'
        - getMethod
    arguments:
        - VisitFrequency.get
```

This depends on your Symfony version (check [here](http://symfony.com/doc/current/components/dependency_injection/factories.html))

### Calling API using Symfony command

[](#calling-api-using-symfony-command)

`devhelp_piwik:api:call` command allows you to call the API from command line. You can do it either by specifying method service id or by passing method name together with api name (or use the default)

for more information please run

```
$ console devhelp_piwik:api:call --help

```

Feedback/Requests
-----------------

[](#feedbackrequests)

Feel free to create an issue if you think that something is missing or needs fixing. Feedback is more than welcome!

Credits
-------

[](#credits)

Brought to you by: [devhelp.pl](http://devhelp.pl)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 95.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~173 days

Recently: every ~206 days

Total

7

Last Release

3004d ago

Major Versions

0.3.2 → 1.02015-12-16

PHP version history (2 changes)0.1PHP &gt;=5.3

1.1PHP &gt;=5.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1479355?v=4)[devhelp](/maintainers/devhelp)[@devhelp](https://github.com/devhelp)

---

Top Contributors

[![pawelbaranski](https://avatars.githubusercontent.com/u/219097?v=4)](https://github.com/pawelbaranski "pawelbaranski (45 commits)")[![kachkaev](https://avatars.githubusercontent.com/u/608862?v=4)](https://github.com/kachkaev "kachkaev (2 commits)")

---

Tags

bundlematomopiwikpiwik-apisymfonypiwik

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/devhelp-piwik-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/devhelp-piwik-bundle/health.svg)](https://phpackages.com/packages/devhelp-piwik-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[cravler/maxmind-geoip-bundle

Bundle integrating MaxMind GeoIP2 database into symfony application

27615.8k2](/packages/cravler-maxmind-geoip-bundle)[components-web-app/api-components-bundle

Creates a flexible API for a website's structure, reusable components and common functionality.

322.8k](/packages/components-web-app-api-components-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
