PHPackages                             blainesch/li3\_fake\_model - 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. blainesch/li3\_fake\_model

ActiveLithium-library[Database &amp; ORM](/categories/database)

blainesch/li3\_fake\_model
==========================

Lithium PHP alternative (fast) model implementation

0.2.2(11y ago)616.5k1[1 issues](https://github.com/BlaineSch/li3_fake_model/issues)MITPHPPHP &gt;=5.3

Since Aug 15Pushed 11y ago3 watchersCompare

[ Source](https://github.com/BlaineSch/li3_fake_model)[ Packagist](https://packagist.org/packages/blainesch/li3_fake_model)[ Docs](https://github.com/BlaineSch/li3_fake_model)[ RSS](/packages/blainesch-li3-fake-model/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (9)Used By (0)

Lithium Fake Model
==================

[](#lithium-fake-model)

*For those times when you don't want a real one*

[![Build Status](https://camo.githubusercontent.com/2e58608f0a196ec78808021e5b5d852d22f82572e0dc562cfc01b288f516ab69/68747470733a2f2f7472617669732d63692e6f72672f626c61696e657363682f6c69335f66616b655f6d6f64656c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/blainesch/li3_fake_model)

This library is for the PHP Lithium Web Framework and provides an alternative to its built-in data models.

It doesn't do much, but that's kinda the point. Here's a comparison:

Lithium ModelsFake ModelsDirty AttributesyesnoFilterable (AOP)yesnoSchema DefinitionyesnoUses LI3 Data Sourcesyesyes \[1\]Works with SQL and Mongoyesmaybe \[2\]Model-level Relationshipsnoyes\[1\] Sort of. We wrap the native LI3 data source in our own to avoid the Document/DocumentSet madness.

\[2\] I've only tested with MongoDB, but Fake Models could be adjusted to work with a SQL data source if someone wants to make the effort.

Then why would I use this?
--------------------------

[](#then-why-would-i-use-this)

You probably shouldn't. I mean, Fake Models do basically nothing! No one in their right mind would make the switch.

OK, to be honest, Lithium Models are bloated and they're slow. They store lots of redundant data, and all the filterable methods (I suspect) contribute to their slowness.

Here are some benchmarks...

CountLithium ModelsFake Modelsfirst()176ms32msall()1002863ms78msEach test was with 100 iterations (divide each by 100 to get true timing).

Relationships
-------------

[](#relationships)

Lithium models support relationships at the data source layer, which works fine for relational databases, but not for MongoDB.

Fake models support relationships at the model level and efficiently eager-loads related records by issuing extra queries. Here's how you use it:

*1. Define your model relationships.*

```
class Posts extends Model {

  public $hasMany = array(
    'Comments' => array(
      'to'        => 'Comments',  // The model
      'key'       => array('_id' => 'comment_id'), // or, you can use an array of foreign keys, e.g. array('comment_ids' => '_id')
      'fieldName' => 'comments',  // The key it's on
      // `order`, `limit`, `conditions` can also be used
    ),
  );

}
```

*2. Query your model and tell it which relationships to fetch.*

```
$posts = Posts::all(array(
  'with' => array('Comments')
));
```

The above query will:

1. query and fetch all the posts
2. issue a second query to get all the comments
3. connect the child comments onto the appropriate parent posts

Relationships can also provide deep query logic:

```
$posts = Posts::all(array(
  'with' => array(
    'comments' => array(
      'order' => array('date' => 'asc'),
      'limit' => 10,
      'conditions' => array(
        'flagged' => false,
      ),
    ),
));
```

Relationships can also be nested further, e.g.:

```
$posts = Posts::all(array(
  'with' => array(
    'Comments' => array('Author')
  )
));
```

This method call still only issues 3 total queries to the Mongo database, yipee!

Copyright and License
---------------------

[](#copyright-and-license)

Fake model is licensed under the MIT License - see the `LICENSE` file for details

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

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.

###  Release Activity

Cadence

Every ~72 days

Recently: every ~89 days

Total

8

Last Release

4192d ago

### Community

Maintainers

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

---

Top Contributors

[![seven1m](https://avatars.githubusercontent.com/u/669?v=4)](https://github.com/seven1m "seven1m (28 commits)")

---

Tags

lithiummodelsli3relations

### Embed Badge

![Health badge](/badges/blainesch-li3-fake-model/health.svg)

```
[![Health](https://phpackages.com/badges/blainesch-li3-fake-model/health.svg)](https://phpackages.com/packages/blainesch-li3-fake-model)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[unionofrad/lithium

The li₃ PHP framework

1.2k171.0k49](/packages/unionofrad-lithium)[mtolhuys/laravel-schematics

A interface to help you build your models

1.5k88.2k1](/packages/mtolhuys-laravel-schematics)[mopo922/laravel-treats

A collection of goodies for Laravel 5.

107472.7k1](/packages/mopo922-laravel-treats)[voskobovich/yii2-linker-behavior

This behavior makes it easy to maintain many-to-many and one-to-many relations in your ActiveRecord models.

79330.6k9](/packages/voskobovich-yii2-linker-behavior)[korridor/laravel-has-many-merged

Custom relationship for Eloquent that merges/combines multiple one-to-may (hasMany) relationships

91132.4k1](/packages/korridor-laravel-has-many-merged)

PHPackages © 2026

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