PHPackages                             lucite/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. lucite/model

ActiveLibrary[Database &amp; ORM](/categories/database)

lucite/model
============

v0.0.7(1y ago)0161MITPHP

Since Sep 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/octoth0rpe/LuciteModel)[ Packagist](https://packagist.org/packages/lucite/model)[ RSS](/packages/lucite-model/feed)WikiDiscussions main Synced 1mo ago

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

lucite/model
============

[](#lucitemodel)

A simple data fetching layer that uses PDO.

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

[](#installation)

`composer require lucite/model`

Usage
-----

[](#usage)

A model defines 5 methods:

- -&gt;fetchOne(int|string $id): array
- -&gt;fetchMany(): array
- -&gt;create(array $data): array
- -&gt;update(int|string $id, array $data): array
- -&gt;delete(int|string $id): void

To create a model, implement a class that extends `Lucite\Model\Model` and define 3 static attributes:

- public static string $tableName # the name of the table to use
- public static string $primaryKey # the name of the table's primary key (compound primary keys are not yet supported)
- public static array $columns # the table's columns, excluding the primary key.

You must also define two methods that are used to apply permissions:

- public function applyPermissionValues(array &amp;$data): void
- public function getPermissionFilter(array &amp;$args): string

If the table in question will never have any permissions enforced, you can use Lucite\\Model\\NoPermissionCheckTrait to add dummy implementations of these methods.

Instantiating a model
---------------------

[](#instantiating-a-model)

The model's constructor requires two parameters:

- PDO $db
- Psr\\Log\\LoggerInterface $logger

You may want to look at lucite/mocklogger for a simple psr-3 logger that can be used for unit testing

Debugging
---------

[](#debugging)

Every time a model runs a query (which might be multiple times per method), two messages are logged using the -&gt;debug method of the logger passed to the model constructor:

- The query, including placeholders (eg, `SELECT id FROM table WHERE id=:id`)
- The args passed to the PDO::Statement -&gt;execute function (eg, `["id" => 4]`)

Implementing permissions
------------------------

[](#implementing-permissions)

Details coming soon, but there is a simple example in `src/Tests/ModelWithPermissionsTest.php`;

Future features
---------------

[](#future-features)

### Add support for 4 parameters to fetchMany

[](#add-support-for-4-parameters-to-fetchmany)

- `int $page`
- `int $pageSize`
- `string $sortColumn`
- `array $filters` (format tbd)

### Support for multicolumn filtering

[](#support-for-multicolumn-filtering)

Details tbd.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

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

Total

7

Last Release

602d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[perplorm/perpl

Perpl is an improved and still maintained fork of Propel2, an open-source Object-Relational Mapping (ORM) for PHP.

203.7k](/packages/perplorm-perpl)

PHPackages © 2026

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