diegorivas89 / laravel-stathat
Laravel 4.2版本Stathat API集成
dev-master
2015-05-02 23:34 UTC
Requires
- php: >=5.4.0
- illuminate/support: 4.2.*
This package is not auto-updated.
Last update: 2024-09-28 17:54:30 UTC
README
Laravel 4版本Stathat API集成
需求
php >= 5.4
illuminate/support: 4.2.*
安装
首先通过Composer安装此包。编辑你的项目中的composer.json
文件,以要求diegorivas89/stathat-laravel
。
"require": {
"diegorivas89/stathat-laravel": "dev-master"
}
接下来,从终端更新Composer
composer update
此操作完成后,添加服务提供者。打开app/config/app.php
,并在提供者数组中添加一个新项。
'Stathat\StathatServiceProvider'
你还可以在app/config/app.php
中aliases
键的末尾添加facade访问器
'Stathat' => 'Stathat\Facades\StathatEz'
或者如果你想使用经典API
'Stathat' => 'Stathat\Facades\StathatClassic'
最后一步是发布配置文件。为此,运行
php artisan config:publish
配置
在发布的文件中,你必须设置你的凭证,这是使用你将要使用的API类型的user_key
和email
。
用法
Stathat::count('page_views'); // default value is 1
Stathat::count('page_views', 2);
Stathat::value('revenue', 17);
或者如果你需要使用多个stathat账户,你可以这样做
Stathat::count('page_views', 1); // default account from config
Stathat::count('page_views', 1, 'first.account@email.com');
Stathat::count('page_views', 1, 'second.account@email.com');