PHP code example of devhelp / piwik-silex-provider
1. Go to this page and download the library: Download devhelp/piwik-silex-provider library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
//'guzzle' service must implement GuzzleHttp\ClientInterface
$app['my_piwik.client'] = $app->share(function () use ($app) {
return new Devhelp\Piwik\Api\Guzzle\Client\PiwikGuzzleClient($app['guzzle']));
});
$app['my_service'] = $app->share(function () use ($app) {
return new Acme\DemoBundle\Service\MyService($app['devhelp_piwik.api']);
});
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();
//...
}
}