dosomething/stathat 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dosomething/stathat

最新稳定版本:v2.0.1

Composer 安装命令:

composer require dosomething/stathat

包简介

Simple API wrapper for StatHat.

README 文档

README

This is a simple, modern API wrapper for StatHat. It also includes optional support for usage as a service in Laravel 5.

Installation

Install with Composer:

"require": {
    "dosomething/stathat": "^2.0.0"
}

Usage

In vanilla PHP, require the Client class and create a new instance with your credentials.

  use DoSomething\StatHat\Client as StatHat;
  
  $stathat = new StatHat([
    'user_key' => '<your_user_key>',       // required for count() and value()
    'ez_key' => 'your_ez_key@example.com', // required for ezCount() and ezValue()
    'access_token' => 'ABC123abc',         // required for AlertsAPI
    'prefix' => 'appname - ',              // optional! will be prepended to EZ stat names
    'debug' => false,                      // optional! will prevent sending stats if true.
  ]);
  
  // And go!
  $stathat->ezCount('<stat_name>', 1);
  $stathat->ezValue('<stat_name>', 15);
  
  $stathat->count('<stat_key>', 1);
  $stathat->value('<stat_key>', 9);

Laravel Usage

Laravel support is built-in. Simply add a service provider & facade alias to your config/app.php:

  'providers' => [
    // ...
    DoSomething\StatHat\StatHatServiceProvider::class,
  ],
  
  'aliases' => [
    // ...
    'StatHat' => DoSomething\StatHat\Facades\StatHat::class
  ],

Finally, add your keys to the config/services.php configuration array:

  'stathat' => [
    'user_key' => '<your_user_key>',       // required for count() and value()
    'ez_key' => 'your_ez_key@example.com', // required for ezCount() and ezValue()
    'prefix' => 'appname - ',              // optional! will be prepended to EZ stat names
    'debug' => env('APP_DEBUG'),           // optional! will prevent sending stats in debug mode.
  ],

The StatHat facade will now be accessible from anywhere in your application:

  StatHat::ezCount('<stat_name>', 1);
  StatHat::ezValue('<stat_name>', 15);
  
  StatHat::count('stat_key', 1);
  StatHat::value('stat_key', 9);

License

©2016 DoSomething.org. StatHat-PHP is free software, and may be redistributed under the terms specified in the LICENSE file. The name and logo for DoSomething.org are trademarks of Do Something, Inc and may not be used without permission.

统计信息

  • 总下载量: 5.09k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 12
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-01