PHPackages                             windwalker/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. [Framework](/categories/framework)
4. /
5. windwalker/model

AbandonedWindwalker-package[Framework](/categories/framework)

windwalker/model
================

Windwalker Model package

2.1.9(10y ago)037[1 issues](https://github.com/ventoviro/windwalker-model/issues)LGPL-2.0+PHPPHP &gt;=5.3.10

Since Oct 5Pushed 10y ago3 watchersCompare

[ Source](https://github.com/ventoviro/windwalker-model)[ Packagist](https://packagist.org/packages/windwalker/model)[ Docs](https://github.com/ventoviro/windwalker-model)[ RSS](/packages/windwalker-model/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (2)Versions (24)Used By (0)

Windwalker Model
================

[](#windwalker-model)

Windwalker Model provides an abstract interface to build your own model logic.

Installation via Composer
-------------------------

[](#installation-via-composer)

Add this to the require block in your `composer.json`.

```
{
    "require": {
        "windwalker/model": "~2.0"
    }
}
```

Create Model
------------

[](#create-model)

Extends the AbstractModel to create your own model.

```
use Windwalker\Model\AbstractModel

class MyModel extends AbstractModel
{
    public function getItem()
    {
        return new stdClass;
    }
}

$model = new MyModel;

$item = $model->getItem();
```

Database Model
--------------

[](#database-model)

Implements the `DatabaseModelInterface`, we will able to get and set a DB object to access database.

Windwalker Model do not dependency to any Database package, you can integrate your favorite data source to get data.

```
use Windwalker\Model\AbstractModel
use Windwalker\Model\DatabaseModelInterface;

class MyModel extends AbstractModel implements DatabaseModelInterface
{
    protected $db;

    public function __construct($db, Registry $state = null)
    {
        $this->db = $db;

        parent::__construct($state);
    }

    public function getDb()
    {
        return $this->db;
    }

    public function setDb($db)
    {
        $this->db = $db;
    }

    public function getList()
    {
        $this->db->setQuery('select * from users');

        return $this->db->loadAll();
    }
}
```

Model State
-----------

[](#model-state)

Model maintains their own state that we can change this state to get different data.

```
class MyModel extends AbstractModel implements DatabaseModelInterface
{
    // ...

    public function getUsers()
    {
        $published = $this->state->get('where.published', 1);

        $ordering  = $this->state->get('list.ordering', 'id');
        $direction = $this->state->get('list.direction', 'ASC');

        $sql = "SELECT * FROM users " .
            " WHERE published = " . $published .
            " ORDER BY " . $ordering . " " . $direction;

        try
        {
            return $this->db->setQuery($sql)->loadAll();
        }
        catch (\Exception $e)
        {
            $this->state->set('error', $e->getMessage());

            return false;
        }
    }
}

$model = new MyModel;

$state = $model->getState();

// Let's change model state
$state->set('where.published', 1);
$state->set('list.ordering', 'birth');
$state->set('list.direction', 'DESC');

$users = $model->getUsers();

if (!$users)
{
    $error = $state->get('error');
}
```

### Simple Way to Access State

[](#simple-way-to-access-state)

Using `get()` and `set()`

```
// Same as getState()->get();
$model->get('where.author', 5);

// Same as getState()->set();
$model->set('list.ordering', 'RAND()');
```

### State ArrayAccess

[](#state-arrayaccess)

```
// Same as getState()->get();
$data = $model['list.ordering'];

// Same as getState()->set();
$model['list.ordering'] = 'created_time';
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity68

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 ~23 days

Recently: every ~46 days

Total

22

Last Release

3748d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1639206?v=4)[Simon Asika](/maintainers/asika32764)[@asika32764](https://github.com/asika32764)

---

Top Contributors

[![asika32764](https://avatars.githubusercontent.com/u/1639206?v=4)](https://github.com/asika32764 "asika32764 (8 commits)")

---

Tags

frameworkmodelwindwalker

### Embed Badge

![Health badge](/badges/windwalker-model/health.svg)

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

PHPackages © 2026

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