PHPackages                             maxcrossan/yii\_encryption - 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. [Security](/categories/security)
4. /
5. maxcrossan/yii\_encryption

ActiveLibrary[Security](/categories/security)

maxcrossan/yii\_encryption
==========================

A simple encryption behaviour for encrypting and decrypting database fields on Yii models

1.1(7y ago)049MITPHP

Since May 22Pushed 7y ago1 watchersCompare

[ Source](https://github.com/maxcrossan/yii_encryption)[ Packagist](https://packagist.org/packages/maxcrossan/yii_encryption)[ RSS](/packages/maxcrossan-yii-encryption/feed)WikiDiscussions master Synced today

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

Encryption Behaviour for Yii
============================

[](#encryption-behaviour-for-yii)

A simple encryption behaviour for encrypting and decrypting database fields on Yii models. After implementation fields configured for encryption will be encrypted the next time the model is saved.

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

[](#installation)

Add the following to your composer file and run `php composer.phar update`

```
    "require": {
        "maxcrossan/yii_encryption": "dev-master"
    },
```

Configure the Yii securityManger component in protected/config/main.php

```
    'components'=>array(
        'securityManager'=>array(
            'cryptAlgorithm' => 'rijndael-128',
            'encryptionKey' => 'your-encryption-key'
        )
    )
```

Usage
-----

[](#usage)

Simply add the following to your model behaviours along with the database columns you want to encrypt:

```
    public function behaviors(){
        return array(
            'EncryptionBehaviour'=>array(
                'class'=>'application.vendor.maxcrossan.yii_encryption.src.EncryptionBehaviour',
                //Add the fields you wish to encrypt below
                'encryptedFields'=>array(
                    'addressLine1',
                    'addressLine2',
                    'lastName',
                    'city',
                    'postcode',
                    'emailAddress',
                    'phone'
                )
            )
        )
    }
```

Any encrypted database columns are best setup with the BLOB db type

Troubleshooting
---------------

[](#troubleshooting)

If you have problems loading the class inside your models you may need to setup an alias for vendor in main.php, something like ` Yii::setPathOfAlias('vendor',dirname(__FILE__).'/../../vendor/');` and then reference the EncryptionBehaviour as `vendor.maxcrossan.yii_encryption.src.EncryptionBehaviour`

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

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

Every ~1 days

Total

2

Last Release

2909d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c3642ab3733ea6c8d8d909d3d25cb4c2f9c6c79f5cf0bb6e641d40333c7542f?d=identicon)[maxcrossan](/maintainers/maxcrossan)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/maxcrossan-yii-encryption/health.svg)

```
[![Health](https://phpackages.com/badges/maxcrossan-yii-encryption/health.svg)](https://phpackages.com/packages/maxcrossan-yii-encryption)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[illuminate/encryption

The Illuminate Encryption package.

9229.7M279](/packages/illuminate-encryption)

PHPackages © 2026

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