PHPackages                             tihloh/prefab-users - 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. tihloh/prefab-users

ActiveLibrary

tihloh/prefab-users
===================

Standalone, framework-independent user management and project-table mapping for Prefab PHP.

v0.1.0(yesterday)02↑2900%MITPHPPHP &gt;=8.1

Since Aug 23Pushed yesterdayCompare

[ Source](https://github.com/tihloh/prefab-users)[ Packagist](https://packagist.org/packages/tihloh/prefab-users)[ Docs](https://github.com/tihloh/prefab-php)[ RSS](/packages/tihloh-prefab-users/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Tihloh Prefab Users
===================

[](#tihloh-prefab-users)

Framework-independent user abstraction and mapping for existing PHP projects.

Prefab Users is standalone. It does not require Prefab Database, Auth, Permissions, Logs, Laravel, or another framework package.

Goals
-----

[](#goals)

- Project keeps ownership of its own `users`, `employees`, or `accounts` table.
- Prefab maps that structure into one reusable `PrefabUser` object.
- Extra project fields remain available as dynamic attributes.
- Projects may return their own `PrefabUser` subclass through `UserFactoryInterface`.
- Database-backed usage accepts plain PDO or Prefab's `DatabaseInterface`.
- Compatible Prefab modules may integrate automatically without becoming dependencies.

Quick standalone usage
----------------------

[](#quick-standalone-usage)

```
use Tihloh\Prefab\Users\Mapping\UserMap;
use Tihloh\Prefab\Users\Repositories\PdoUserProvider;
use Tihloh\Prefab\Users\Services\UserManager;

$map = new UserMap(
    table: 'employees',
    id: 'employee_id',
    name: 'full_name',
    email: 'email_address',
    active: 'is_active',
    attributes: [
        'office' => 'office_name',
        'position' => 'position_title',
        'employee_no' => 'employee_no',
    ],
    allowDelete: false,
);

$users = new UserManager(
    new PdoUserProvider($pdo, $map),
);

$user = $users->find(25);
```

The historical `PdoUserProvider` class name is retained for compatibility, but the provider now consumes `DatabaseInterface` internally. Passing PDO is automatically adapted.

Automatic database configuration
--------------------------------

[](#automatic-database-configuration)

A project may configure Users directly:

```
$users = new UserManager([
    'database' => $pdo,
    'map' => $map,
]);
```

or centrally:

```
PrefabConfig::set([
    'database' => $pdo,

    'modules' => [
        'users' => [
            'map' => $map,
        ],
    ],
]);

$users = new UserManager();
```

When Prefab Database exists, Users can inherit its default or a named connection automatically:

```
$database = new DatabaseManager([
    'default' => 'main',
    'connections' => [
        'main' => $mainPdo,
    ],
]);

$users = new UserManager();
```

The database resolution priority is:

```
1. direct Users database / connection
2. Users-specific PrefabConfig
3. common PrefabConfig
4. compatible database capability
5. clear error if a database-backed provider is still unresolved

```

Database abstraction
--------------------

[](#database-abstraction)

Prefab Users does not require a concrete database package. Its built-in database provider accepts either:

```
PDO
DatabaseInterface

```

Plain PDO is normalized automatically:

```
PDO
 ↓
PdoDatabaseAdapter
 ↓
DatabaseInterface
 ↓
PdoUserProvider

```

This allows future framework adapters to supply the same contract without changing UserManager.

CRUD
----

[](#crud)

```
$users->all();
$users->find(25);
$users->findByEmail('user@example.com');
$users->create([...]);
$users->update(25, [...]);
$users->delete(25);
```

Write operations are controlled by `UserMap` capabilities: `allowCreate`, `allowUpdate`, and `allowDelete`.

Custom user class
-----------------

[](#custom-user-class)

Extend `PrefabUser`:

```
use Tihloh\Prefab\Users\User\PrefabUser;

class Employee extends PrefabUser
{
    public function displayName(): string
    {
        return $this->name . ' - ' . ($this->position ?? '');
    }
}
```

Then implement `UserFactoryInterface` and pass the factory to the database provider. This keeps the project-owned schema reusable while allowing project-specific user behavior.

Automatic cooperation
---------------------

[](#automatic-cooperation)

When compatible modules are present, Users may automatically:

- provide `user_provider` for Prefab Auth;
- publish its resolved database as a low-priority fallback capability;
- use Prefab Logs for activity recording;
- use Prefab Auth as the current actor provider.

None of those modules are required.

Use:

```
$users->explain();
```

to inspect how Users resolved its provider, database, table, logger, and actor integrations.

HTTP
----

[](#http)

`Http\UserController` is transport-neutral and returns arrays suitable for JSON serialization. Routers may map it to endpoints such as:

- `GET /api/v1/users`
- `GET /api/v1/users/{id}`
- `POST /api/v1/users`
- `PUT /api/v1/users/{id}`
- `DELETE /api/v1/users/{id}`

The HTTP layer uses the same `UserManager` as direct Composer usage.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ec00222b22ba37eb69aff9973c5303fe5773cb4c7016bf0e7aae09fe9edb232?d=identicon)[tihloh](/maintainers/tihloh)

---

Top Contributors

[![tihloh](https://avatars.githubusercontent.com/u/8960509?v=4)](https://github.com/tihloh "tihloh (41 commits)")

---

Tags

phpUser managementUsersmodularprefabframework-independent

### Embed Badge

![Health badge](/badges/tihloh-prefab-users/health.svg)

```
[![Health](https://phpackages.com/badges/tihloh-prefab-users/health.svg)](https://phpackages.com/packages/tihloh-prefab-users)
```

###  Alternatives

[tomatophp/filament-users

Manage your users with a highly customizable user resource for FilamentPHP with integration of filament-shield and filament-impersonate

90136.4k11](/packages/tomatophp-filament-users)[gacela-project/gacela

Gacela helps you separate your project into modules

134203.7k16](/packages/gacela-project-gacela)[oleksandr-torosh/yona-cms

Yona CMS - open source content management system (CMS). Written in Phalcon PHP Framework (v 1.3.x). Has a convenient modular structure. Has simple configuration and architecture. Can be easily modified for any task with any loads.

3642.1k](/packages/oleksandr-torosh-yona-cms)

PHPackages © 2026

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