dekalee/adback-analytics
Composer 安装命令:
composer require dekalee/adback-analytics
包简介
A php lib to call the AdBack api
README 文档
README
This PHP library will call the AdBack API and will generate the JavaScript tag that should be placed on all the pages.
See the AdBack website for more informations.
See the AdBack documentation for an installation guide.
Usage
Both the Query and Generators will need a driver which implements
the ScriptCacheInterface to work.
A driver for Redis is already available.
Usage Exemple
Installation
Use composer to install the lib :
composer require dekalee/adback-analytics
Usage with Redis
Query the api
First you need to query the api to warmup the cache in a Redis data store :
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();
Generate the scripts
In your page, preferably in the <head>, use the generator to create the script :
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();
You could do the same to create the other scripts by using the appropriate generators.
Usage with MySQL
Create the table
To create the table used to store the data in MySQL, run the query:
CREATE TABLE adback_cache_table( our_key varchar(255), our_value varchar(255));
With the PDO driver
Query the api
First you need to query the api to warmup the cache in a Mysql table :
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();
Generate the scripts
In your page, preferably in the <head>, use the generator to create the script :
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();
You could do the same to create the other scripts by using the appropriate generators.
With the Mysqli driver
Query the api
First you need to query the api to warmup the cache in a Mysql table :
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();
Generate the scripts
In your page, preferably in the <head>, use the generator to create the script :
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();
You could do the same to create the other scripts by using the appropriate generators.
dekalee/adback-analytics 适用场景与选型建议
dekalee/adback-analytics 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.42k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 01 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dekalee/adback-analytics 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dekalee/adback-analytics 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 10.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2017-01-10