PHP code example of mach / piwik-proxy-service-provider

1. Go to this page and download the library: Download mach/piwik-proxy-service-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/ */

    

mach / piwik-proxy-service-provider example snippets

 composer.phar 
 composer.phar update mach/piwik-proxy-service-provider



use Silex\Application;
use Mach\Silex\Piwik\PiwikProxyServiceProvider;

$app = new Application();
$app->register(new PiwikProxyServiceProvider(), array(
    'piwik.proxy.url' => 'http://piwik.example.com',
    'piwik.proxy.token' => 'xyz',
));



$app->get('/tracker', function(Request $request) use ($app) {
    return $app['piwik.proxy']($request);
});



$app->get('/tracker/{id}', function(Request $request, $id) use ($app) {
    return $app['piwik.proxy']($request, array(
        'url' => "https://piwik-$id.example.com"
    ));
});
file_get_contents
file_get_contents