PHPackages                             illusorium/kthrottler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. illusorium/kthrottler

ActiveKohana-module[Utility &amp; Helpers](/categories/utility)

illusorium/kthrottler
=====================

Kthrottler Kohana module as a composer package

0101

Since Dec 19Compare

[ Source](https://github.com/illusorium/kthrottler)[ Packagist](https://packagist.org/packages/illusorium/kthrottler)[ RSS](/packages/illusorium-kthrottler/feed)WikiDiscussions Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

[![](https://camo.githubusercontent.com/376f82e9a7a1e1b7d2e1307985f3bb2c1dcc3d8bd14f7c6b8edf3e0657bdc6c3/687474703a2f2f7374696c6c6d61696e7461696e65642e636f6d2f6672656477752f6b7468726f74746c65722e706e67)](http://stillmaintained.com/fredwu/kthrottler)

KThrottler
==========

[](#kthrottler)

There is also a Ruby version (for [Rails](http://rubyonrails.org/)), see here: [http://github.com/fredwu/action\_throttler](http://github.com/fredwu/action_throttler)

Introduction
------------

[](#introduction)

KThrottler is an easy to use Kohana module to quickly throttle application actions based on configurable duration and limit.

Brought to you by [Wuit](http://wuit.com).

Features
--------

[](#features)

- Easy to use, easy to configure
- Lightweight
- Supports Kohana v3

Prerequisites
-------------

[](#prerequisites)

- Kohana's built-in DB module

Usage
-----

[](#usage)

### Download and install the module

[](#download-and-install-the-module)

```
git clone git://github.com/fredwu/kthrottler.git

```

### Enable the module

[](#enable-the-module)

In your bootstrap file (`application/bootstrap.php`), enable KThrottler like this:

```
Kohana::modules(array(
	'database'    => MODPATH.'database',
    'kthrottler'  => MODPATH.'kthrottler',
));

```

### Set up the database table

[](#set-up-the-database-table)

Import the `kthrottler_logs_db.sql` file supplied.

### Configure the actions

[](#configure-the-actions)

The configuration file is located at `config/kthrottler.php`. Please copy it to your `application/config` folder.

The configuration array looks like this:

```
return array
(
	'mail' => array
	(
		'duration' => '1 hour',
		'limit'    => 10,
	),
);

```

You can add as many configuration elements as you like, just make sure you label them properly (i.e. like `mail` in the example).

In the example, we are setting the `mail` action to perform at most 10 times within 1 hour duration.

### Register the actions in your app

[](#register-the-actions-in-your-app)

Now we will need to register the actions so they are recorded in the database.

To simply run an action, in your app (presumably somewhere in the controller), do this:

```
KThrottler::actions()->run('mail');

```

`KThrottler::actions()->run()` will return true or false depending on whether or not the action is being throttled.

`KThrottler::actions()->run()` has an alias `KThrottler::actions()->can_run()` and a negative alias `KThrottler::actions()->cannot_run()`.

Typically, we would want to produce feedback to the user when an action is throttled, you can do so by:

```
if (`KThrottler::actions()->cannot_run('mail')`)
	// tell the user that this action is not performed
end

```

`KThrottler::actions()->run()` also takes an optional reference parameter:

`KThrottler::actions()->run('mail', $current_user)`

The reference parameter is very useful because we can track and throttle the action based on a reference, such as a user. The parameter accepts a String, an Integer or an ORM object.

Note that `KThrottler::actions()->run()` and its aliases will perform the action when possible. If you only want to check to see if an action can be performed, you can do this:

```
`KThrottler::actions()->can_be_run('mail', $current_user)`

```

`KThrottler::actions()->can_be_run()` returns true or false without performing the action, and it also has a negative alias, `KThrottler::actions()->cannot_be_run()`.

Author
------

[](#author)

Copyright (c) 2010 Fred Wu () and [Wuit](http://wuit.com), released under the MIT license

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b54194f23f92f5ac94479ce84ee3588bb422f2cf64a7cc358ec57ae529d202e9?d=identicon)[illusorium](/maintainers/illusorium)

### Embed Badge

![Health badge](/badges/illusorium-kthrottler/health.svg)

```
[![Health](https://phpackages.com/badges/illusorium-kthrottler/health.svg)](https://phpackages.com/packages/illusorium-kthrottler)
```

###  Alternatives

[dipeshsukhia/laravel-html-minify

laravel minify html output

7780.9k](/packages/dipeshsukhia-laravel-html-minify)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
