owlgrin/throttle
最新稳定版本:v0.2.0
Composer 安装命令:
composer require owlgrin/throttle
包简介
Rate Limiter and Usage tracker
README 文档
README
Throttle allows you to maintain a integration between your plans and your features.
Installation
To install the package, include the following in your composer.json.
"owlgrin/throttle": "dev-master"
And then include the following service provider in your app.php.
'Owlgrin\Throttle\ThrottleServiceProvider'
And lastly, publish the config.
php artisan config:publish owlgrin/throttle
Usage
Write this command in your artisan to create migrations
throttle:table
Now migrate all the tables to your mysql db
php artisan migrate
Entry of New Plan
Its time to create a new plan by using Owlgrin\Plan\PlanRepo 's add function
plan's format is as follows
$plan = {
"plan":{
"name" : "Simple",
"identifier" :"simple",
"description" :"this is a simple plan",
"features": [
{
"name":"Horn",
"identifier":"horn",
"tier" :[
{
"rate":"4",
"per_quantity":1,
"limit":"500"
},
{
"rate":"3",
"per_quantity":1,
"limit":"5000"
}
]
},
{
"name":"Mail",
"identifier":"mail",
"tier" :[
{
"rate":"4",
"per_quantity":1,
"limit":"100"
},
{
"rate":"3",
"per_quantity":1,
"limit":"1000"
}
]
}
]
}
}
Subscription of user
You can subscribe a user with plan id by using
Owlgrin\Throttle\Subscriber\SubscriberRepo
subscribe($userId, $planId)
Biller
You can calculate the bill by just using
Owlgrin\Throttle\Biller\Biller
calculate($userId)
or can estimate bill by
estimate($plan)
$plan = {'plan_id':1,
'feature':{
{feature_id}:{usage},
{feature_id}:{usage}
}
}
统计信息
- 总下载量: 372
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-27