PHPackages                             imsamurai/cakephp-serializable-behaviour - 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. [Database &amp; ORM](/categories/database)
4. /
5. imsamurai/cakephp-serializable-behaviour

ActiveCakephp-plugin[Database &amp; ORM](/categories/database)

imsamurai/cakephp-serializable-behaviour
========================================

Behavior for saving and reading serialized data from/into database

1.0.6(11y ago)147.7k3[1 issues](https://github.com/imsamurai/cakephp-serializable-behaviour/issues)3MITPHP

Since Jan 18Pushed 11y ago1 watchersCompare

[ Source](https://github.com/imsamurai/cakephp-serializable-behaviour)[ Packagist](https://packagist.org/packages/imsamurai/cakephp-serializable-behaviour)[ Docs](http://github.com/imsamurai/cakephp-serializable-behaviour)[ RSS](/packages/imsamurai-cakephp-serializable-behaviour/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (8)Used By (3)

API Documentation
-----------------

[](#api-documentation)

Check out [Serializable Behavior API Documentation](http://imsamurai.github.io/cakephp-serializable-behaviour/docs/master/)

Abstract
--------

[](#abstract)

[![Build Status](https://camo.githubusercontent.com/f35f466d1f6ad0b35da38ab1ef690c341c587d6b1e5fc23fa4c50fe9f3e51b16/68747470733a2f2f7472617669732d63692e6f72672f696d73616d757261692f63616b657068702d73657269616c697a61626c652d6265686176696f75722e706e67)](https://travis-ci.org/imsamurai/cakephp-serializable-behaviour) [![Coverage Status](https://camo.githubusercontent.com/dbe3860243dcaf99e4742093dd37ab2e5c6747b1288c3cf4cdd8ae3d5c5b80e7/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f696d73616d757261692f63616b657068702d73657269616c697a61626c652d6265686176696f75722f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/imsamurai/cakephp-serializable-behaviour?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/edcee7233ecce3a9e1d8fb31525bd23d345f7cd98f016bc72ed4c606f681a9fc/68747470733a2f2f706f7365722e707567782e6f72672f696d73616d757261692f63616b657068702d73657269616c697a61626c652d6265686176696f75722f762f737461626c652e706e67)](https://packagist.org/packages/imsamurai/cakephp-serializable-behaviour) [![Total Downloads](https://camo.githubusercontent.com/6834be2320270213c17c1ba872c25ee148f059f9f76bad92da27977ead7a9768/68747470733a2f2f706f7365722e707567782e6f72672f696d73616d757261692f63616b657068702d73657269616c697a61626c652d6265686176696f75722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/imsamurai/cakephp-serializable-behaviour) [![Latest Unstable Version](https://camo.githubusercontent.com/0c50e2c82ed63d642b041510c70f72328aeb26c82dfec8861cbfcfadaa651c40/68747470733a2f2f706f7365722e707567782e6f72672f696d73616d757261692f63616b657068702d73657269616c697a61626c652d6265686176696f75722f762f756e737461626c652e706e67)](https://packagist.org/packages/imsamurai/cakephp-serializable-behaviour) [![License](https://camo.githubusercontent.com/3654d539c39e0690525fc8314cefb8577b79232ccb989cc268a44f75a98ae772/68747470733a2f2f706f7365722e707567782e6f72672f696d73616d757261692f63616b657068702d73657269616c697a61626c652d6265686176696f75722f6c6963656e73652e706e67)](https://packagist.org/packages/imsamurai/cakephp-serializable-behaviour)

Serializable Behaviour for CakePHP 2.1+

Use it if you want to save and read serialized data into db.

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

[](#installation)

```
cd my_cake_app/app
git clone git://github.com/imsamurai/cakephp-serializable-behaviour.git Plugin/Serializable

```

or if you use git add as submodule:

```
cd my_cake_app
git submodule add "git://github.com/imsamurai/cakephp-serializable-behaviour.git" "app/Plugin/Serializable"

```

then add plugin loading in Config/bootstrap.php

```
CakePlugin::load('Serializable');

```

Configuration
-------------

[](#configuration)

Write global config if you need to use custom serialization function:

```
Configure::write('Serializable', array(
  'serialize' => ,
  'unserialize' =>
));

```

Attach behaviour to model:

```
public $actsAs = array(
      'Serializable.Serializable' => array(
        'fields' => ,
        'serialize' => , // optional
        'unserialize' =>  // optional
        'merge' => true // optional
      )
);

```

By default serialization uses function `serialize`, unserialization - `unserialize`Merging is off by default, turning it on will do a recursive merge on existing records so you can add data without replacing the entire serialized object.

Advanced usage
--------------

[](#advanced-usage)

If you want to use serialization with Containable behaviour you must modify your AppModel. For example we have 3 models that extedned AppModel: NewsPopular has many NewsPopularItem NewsPopularItem belongs to Article

NewsPopularItem and Article has some serialized fields.

Assume you want to fetch data this way:

```
$this->NewsPopular->contain(array(
		'NewsPopularItem' => array(
			'Article'
		)
	));
$data = $this->NewsPopular->find('first');

```

In this case you must add some configuration to AppModel::afterFind. In basic case there must be:

```
public function afterFind($results, $primary = false) {
	if (!$primary && $this->Behaviors->enabled('Serializable')) {
		return $this->Behaviors->Serializable->afterFind($this, $results, $primary);
	}
	return parent::afterFind($results, $primary);
}

```

And that's all! Now you have data structure with unserialized fields.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 62.5% 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 ~87 days

Recently: every ~69 days

Total

7

Last Release

4025d ago

### Community

Maintainers

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

---

Top Contributors

[![imsamurai](https://avatars.githubusercontent.com/u/843002?v=4)](https://github.com/imsamurai "imsamurai (10 commits)")[![letstalk-nl](https://avatars.githubusercontent.com/u/9513230?v=4)](https://github.com/letstalk-nl "letstalk-nl (6 commits)")

---

Tags

databasecakephpserializablebehaviour

### Embed Badge

![Health badge](/badges/imsamurai-cakephp-serializable-behaviour/health.svg)

```
[![Health](https://phpackages.com/badges/imsamurai-cakephp-serializable-behaviour/health.svg)](https://phpackages.com/packages/imsamurai-cakephp-serializable-behaviour)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[dereuromark/cakephp-databaselog

A CakePHP plugin for storing and viewing application logs in the database

44170.0k2](/packages/dereuromark-cakephp-databaselog)

PHPackages © 2026

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