PHPackages                             itarato/micmod - 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. itarato/micmod

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

itarato/micmod
==============

04PHP

Since Mar 13Pushed 11y agoCompare

[ Source](https://github.com/itarato/micmod)[ Packagist](https://packagist.org/packages/itarato/micmod)[ RSS](/packages/itarato-micmod/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Micro Model Layer
=================

[](#micro-model-layer)

[![Build Status](https://camo.githubusercontent.com/43762c0df5e7b8fd1e6490ea5b98931788ffa8903a96b18019a897fc28f54bd7/68747470733a2f2f7472617669732d63692e6f72672f6974617261746f2f6d69636d6f642e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/itarato/micmod)

Micro model layer is micro-library to provide convenient CRUD operations for models. It's using annotations to mark properties as part of the storage and there is an extensible storage api to handle persistence.

At the moment a Drupal 7 storage implementation is implemented in the library.

Here a *model* should be as pure as possible. Because of annotations it can clearly separate the model properties from management props, however non strictly model elements should be moved out to different units (such as controllers).

Install
-------

[](#install)

Add the composer package as a dependency:

```
require: {"itarato/micmod": "dev-master"}

```

Usage - with Drupal
-------------------

[](#usage---with-drupal)

First you either create a model or add the base class to an existing model. The pure

```
/**
 * @table micmod
 */
class ExampleModel extends \Micmod\Model\DrupalModel {

  /**
   * @column id
   * @primary-key
   */
  public $id;

  /**
   * @column name
   */
  public $name;

}
```

Create new object - instantiate the class and fill out the properties:

```
$item = new \ExampleModel();
$item->id = 123;
$item->name = 'Jason';
$item->save();
```

Load object - instantiate the class and set the primary keys:

```
$item = new \ExampleModel();
$item->id = 123;
$item->load();
echo $item->name;
```

Update object - load or instantiate the object, change the non primary key fields and update (non loaded ((NULL)) properties will not be set):

```
$item = new \ExampleModel();
$item->id = 123;
$item->name = 'Richard';
$item->update();
```

Delete new object - set the primary keys and delete:

```
$item = new \ExampleModel();
$item->id = 123;
$item->Delete();
```

Annotations
-----------

[](#annotations)

**Table name**:

Defines the table the model is stored in.

Tag: 'table'

Example:

```
/**
 * @table TABLENAME
 */
```

**Column name**:

Defines the table column name the of the property. Column name and variable name can be different.

Tag: 'column'

Example:

```
/**
 * @column COLUMN_NAME
 */
public $userName;
```

**Primary key**:

Marks a property a primary key. There has to be one primary key at least, but there can be more.

Tag: 'primary-key'

Example

```
/**
 * @column COLUMN_NAME
 * @primary-key
 */
public $userName;
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

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

---

Top Contributors

[![itarato](https://avatars.githubusercontent.com/u/49009?v=4)](https://github.com/itarato "itarato (10 commits)")

### Embed Badge

![Health badge](/badges/itarato-micmod/health.svg)

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

PHPackages © 2026

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