PHPackages                             sizeg/yii2-newton-cool-ranking-behavior - 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. sizeg/yii2-newton-cool-ranking-behavior

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

sizeg/yii2-newton-cool-ranking-behavior
=======================================

Yii2 Newton cool ranking behavior

v1.0.0(10y ago)48.7k↓82.4%MITPHP

Since Jun 21Pushed 10y ago1 watchersCompare

[ Source](https://github.com/sizeg/yii2-newton-cool-ranking-behavior)[ Packagist](https://packagist.org/packages/sizeg/yii2-newton-cool-ranking-behavior)[ Docs](https://github.com/sizeg/yii2-newton-cool-ranking-behavior)[ RSS](/packages/sizeg-yii2-newton-cool-ranking-behavior/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Yii2 Newton Cool Ranking Behavior
=================================

[](#yii2-newton-cool-ranking-behavior)

This behavior provides the algorithm of rank hotness with Newton's law of cooling explained by [Evan Miller](http://www.evanmiller.org/).

You can use it to rate comments or blog posts. Listing active discussion threads in an online forum.

Read this article [Rank Hotness With Newton's Law of Cooling](http://www.evanmiller.org/rank-hotness-with-newtons-law-of-cooling.html) for more details.

Installation
------------

[](#installation)

Package is available on [Packagist](https://packagist.org/packages/sizeg/yii2-newton-cool-ranking-behavior), you can install it using [Composer](http://getcomposer.org).

```
composer require sizeg/yii2-newton-cool-ranking-behavior
```

### Dependencies

[](#dependencies)

- Yii2 (testing with 2.8, but should work with lower versions)

Basic usage
-----------

[](#basic-usage)

Create migration,

```
public function up()
{
    // [[NewtonCoolRankingBehavior::$rankAttribute]]
    $this->addColumn('{{%tableName}}', 'rank', $this->float());

    // [[NewtonCoolRankingBehavior::$rankTimeAttribute]]
    // By default time update with result of php time() function
    // For example we will use DateTime instead of UnixTimestamp
    $this->addColumn('{{%tableName}}', 'rankTime', $this->datetime());

    // [[NewtonCoolRankingBehavior::$rankBoostAttribute]]
    // This field is optional
    $this->addField('{{%tableName}}', 'rankBoost', $this->float());
}
```

Add behavior to your ActiveRecord model,

```
class Item extends \yii\base\ActiveRecord
{
    public function behaviors()
    {
        return \yii\helpers\ArrayHelper::merge(parent::behaviors(), [
            [
                'class' => 'sizeg\newtoncoolranking\NewtonCoolRankingBehavior',
                // optional params
                'initial' => 1000,
                'coolingRate' => 150,
                'timeValue' => date('Y-m-d H:i:s'), // can be a callback function
            ]
        ]);
    }
}
```

By default the new model would have \[\[NewtonCoolRankingBehavior::$initial\]\] value and will cooling with \[\[NewtonCoolRankingBehavior::$coolingRate\]\].

When there is new activity on an model, you need update rank,

```
/** @var ActiveRecord $model */
$model->heat(20);
```

Sometimes you need one or more models to show in top for a few days, then you need to boost it.

Boost value will be received from model \[\[NewtonCoolRankingBehavior::$rankBoostAttribute\]\] field. If field doesn't exist, the value will be received from optional \[\[NewtonCoolRankingBehavior::$boost\]\] attribute.

```
/** @var ActiveRecord $model */
$model->boost();
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3666d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/383378?v=4)[SiZE](/maintainers/SiZE)[@SiZe](https://github.com/SiZe)

---

Top Contributors

[![sizeg](https://avatars.githubusercontent.com/u/4047591?v=4)](https://github.com/sizeg "sizeg (1 commits)")

---

Tags

yii2Behaviornewton

### Embed Badge

![Health badge](/badges/sizeg-yii2-newton-cool-ranking-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/sizeg-yii2-newton-cool-ranking-behavior/health.svg)](https://phpackages.com/packages/sizeg-yii2-newton-cool-ranking-behavior)
```

###  Alternatives

[baibaratsky/yii2-serialized-attributes-behavior

Yii2 Serialized Attributes Behavior

1275.5k9](/packages/baibaratsky-yii2-serialized-attributes-behavior)[mdmsoft/yii2-autonumber

Auto number extension for the Yii framework

1831.3k](/packages/mdmsoft-yii2-autonumber)[asinfotrack/yii2-audittrail

Yii2-audittrail is a behavior and a set of widgets to track all modifications performed on a model

1727.5k](/packages/asinfotrack-yii2-audittrail)[valentinek/yii2-closure-table-behavior

This extension allows you to get functional for closure table trees.

1615.5k](/packages/valentinek-yii2-closure-table-behavior)[v0lume/yii2-meta-tags

DB based model meta data for SEO

204.1k](/packages/v0lume-yii2-meta-tags)

PHPackages © 2026

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