PHPackages                             budipratama/yii2-ipbehaviors - 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. budipratama/yii2-ipbehaviors

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

budipratama/yii2-ipbehaviors
============================

Ip Behaviors

11PHP

Since Sep 6Pushed 3y ago1 watchersCompare

[ Source](https://github.com/budipratama/yii2-ipbehaviors)[ Packagist](https://packagist.org/packages/budipratama/yii2-ipbehaviors)[ RSS](/packages/budipratama-yii2-ipbehaviors/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Ip Behaviors
============

[](#ip-behaviors)

Ip Behaviors

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist budipratama/yii2-ipbehaviors "@dev"

```

or add

```
"budipratama/yii2-ipbehaviors": "@dev"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

IpBehaviors automatically fills the specified attributes with the current ip user login. To use IpBehaviors, insert the following code your ActiveRecord class:

```
use budipratama\behaviors\IpBehaviors;

 public function behaviors()
 {
     return [
           [
               'class' => IpBehaviors::class
           ],
     ];
 }
```

By default, IpBehaviors will fill the first\_ip and last\_ip attributes with the current ip user when created row the associated AR object is being inserted. it will fill the last\_ip attribute with the ip when the AR object is being updated. The ip value is obtained by Yii::$app-&gt;request-&gt;userIp. Because attribute values will be set automatically by this behavior, they are usually not user input and should therefore not be validated, i.e. first\_ip and last\_ip should not appear in the rules() method of the model. For the above implementation to work with MySQL database, please declare the columns(first\_ip, last\_ip) as varchar(15). If your attribute names are different, you may configure the $createdAtAttribute, $updatedAtAttribute and $value properties like the following:

```
 public function behaviors()
 {
     return [
           [
               'class' => IpBehaviors::class,
               'createdAtAttribute' => 'first_ip',
               'updatedAtAttribute' => 'last_ip',
               'value' => function(){
                   return \Yii::$app->request->userIp;
               }
           ],
     ];
 }
```

###  Health Score

14

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

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/8cfbc55411a4bf79e678278098bb7d3cc62705632e7d62d84c37ba76c16e02bf?d=identicon)[budipratama](/maintainers/budipratama)

### Embed Badge

![Health badge](/badges/budipratama-yii2-ipbehaviors/health.svg)

```
[![Health](https://phpackages.com/badges/budipratama-yii2-ipbehaviors/health.svg)](https://phpackages.com/packages/budipratama-yii2-ipbehaviors)
```

###  Alternatives

[tobiassjosten/boris-loader

Loads project specific contexts into Boris REPL

2830.1k](/packages/tobiassjosten-boris-loader)[dxw/whippet

14110.8k](/packages/dxw-whippet)

PHPackages © 2026

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