PHP code example of dekalee / adback-analytics

1. Go to this page and download the library: Download dekalee/adback-analytics 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/ */

    

dekalee / adback-analytics example snippets


    composer 

    use Dekalee\AdbackAnalytics\Client\Client;
    use Dekalee\AdbackAnalytics\Driver\RedisScriptCache;
    use Dekalee\AdbackAnalytics\Query\ScriptUrlQuery;

    function createApiCache()
    {
        $client = new Client();
        $redis = new \Redis();
        $redis->connect('127.0.0.1');
        $redisCache = new RedisScriptCache($redis);

        $query = new ScriptUrlQuery($client, $redisCache, 'your-token');
        $query->execute();
    }

    createApiCache();

    use Dekalee\AdbackAnalytics\Driver\RedisScriptCache;
    use Dekalee\AdbackAnalytics\Generator\AnalyticsScriptGenerator;

    function generateAnalyticsScript()
    {
        $redis = new \Redis();
        $redis->connect('127.0.0.1');
        $redisCache = new RedisScriptCache($redis);
        $generator = new AnalyticsScriptGenerator($redisCache);

        return $generator->generate();
    }

    echo generateAnalyticsScript();

    use Dekalee\AdbackAnalytics\Client\Client;
    use Dekalee\AdbackAnalytics\Driver\PdoScriptCache;
    use Dekalee\AdbackAnalytics\Query\ScriptUrlQuery;

    function createApiCache()
    {
        $client = new Client();
        $connection = new \PDO('mysql:host=your-database-host;dbname=your-database;charset=utf8', 'login', 'password');
        $cache = new PdoScriptCache($connection);

        $query = new ScriptUrlQuery($client, $cache, 'your-token');
        $query->execute();
    }

    createApiCache();

    use Dekalee\AdbackAnalytics\Generator\AnalyticsScriptGenerator;
    use Dekalee\AdbackAnalytics\Driver\PdoScriptCache;


    function generateAnalyticsScript()
    {
        $connection = new \PDO('mysql:host=your-database-host;dbname=your-database;charset=utf8', 'login', 'password');
        $cache = new PdoScriptCache($connection);
        $generator = new AnalyticsScriptGenerator($cache);

        return $generator->generate();
    }

    echo generateAnalyticsScript();

    use Dekalee\AdbackAnalytics\Client\Client;
    use Dekalee\AdbackAnalytics\Driver\MysqliScriptCache;
    use Dekalee\AdbackAnalytics\Query\ScriptUrlQuery;

    function createApiCache()
    {
        $client = new Client();
        $connection = new \mysqli('your-database-host', 'login', 'password', 'your-database');
        $cache = new MysqliScriptCache($connection);

        $query = new ScriptUrlQuery($client, $cache, 'your-token');
        $query->execute();
    }

    createApiCache();

    use Dekalee\AdbackAnalytics\Generator\AnalyticsScriptGenerator;
    use Dekalee\AdbackAnalytics\Driver\PdoScriptCache;


    function generateAnalyticsScript()
    {
        $connection = new \mysqli('your-database-host', 'login', 'password', 'your-database');
        $cache = new MysqliScriptCache($connection);
        $generator = new AnalyticsScriptGenerator($cache);

        return $generator->generate();
    }

    echo generateAnalyticsScript();