PHPackages                             locomotivemtl/charcoal-user - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. locomotivemtl/charcoal-user

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

locomotivemtl/charcoal-user
===========================

User definition, authentication and authorization.

0.7.0.2(4y ago)013.7k3MITPHPPHP &gt;7.1CI failing

Since Jan 19Pushed 4y ago12 watchersCompare

[ Source](https://github.com/locomotivemtl/charcoal-user)[ Packagist](https://packagist.org/packages/locomotivemtl/charcoal-user)[ RSS](/packages/locomotivemtl-charcoal-user/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (13)Versions (39)Used By (3)

Charcoal User
=============

[](#charcoal-user)

User defintion (as Charcoal Model), authentication and authorization (with Laminas ACL).

Table of content
================

[](#table-of-content)

- [How to install](#how-to-install)
    - [Dependencies](#dependencies)
- [The User object](#the-user-object)
- [Authentication](#authentication)
- [Authorization](#authorization)
- [Development](#development)
    - [Development dependencies](#development-dependencies)
    - [Continuous Integration](#continuous-integration)
    - [Coding Style](#coding-style)
    - [Authors](#authors)

How to install
==============

[](#how-to-install)

The preferred (and only supported) way of installing *charcoal-user* is with **composer**:

```
★ composer require locomotivemtl/charcoal-user
```

Dependencies
------------

[](#dependencies)

- PHP 7.1+
- `laminas/laminas-permissions-acl`
- `locomotivemtl/charcoal-object`

The User object
===============

[](#the-user-object)

At the core of this module is the definition of a "User" object. The contract can be found as `\Charcoal\User\UserInterface`. This interfaces extends `\Charcoal\Object\ContentInterface` (from `locomotivemtl/charcoal-object`), which extends `\Charcoal\Model\ModelInterface` (from `locomotivemtl/charcoal-core`).

The preferred way of using this module is by defining your own User class in your project and extending the provided `\Charcoal\User\AbstractUser` class.

For quick prototypes or small projects, a full concrete class is provided as `\Charcoal\User\GenericUser`.

User properties
---------------

[](#user-properties)

PropertyTypeDefaultDescription**username**`string``true`…**password**`string``null`…**email**`string``null`…**roles**`string[]``[]`ACL roles, which define user permissions.**last\_login\_date**`date-time``null`…**last\_login\_ip**`string``''`…**last\_password\_date**`date-time``null`…**last\_password\_ip**`string``''`…**login\_token**`string``null`…> Note that the `key` of the User is the `username`. Therefore, `id()` returns the username. It must be unique.

**Properties inherited from `Content-Interface`:**

PropertyTypeDefaultDescription**active**`boolean``true`…**position**`number``null`…**created**`date-time``null`…**created\_by**`string``''`…**last\_modified**`date-time``null`…**last\_modified\_by**`string``''`…Authentication
==============

[](#authentication)

...

Authentication Examples
-----------------------

[](#authentication-examples)

...

Authorization
=============

[](#authorization)

User authorization is managed with a role-based *Access Control List* (ACL). Internally, it uses [`laminas/laminas-permissions-acl`](https://github.com/laminas/laminas-permissions-acl) for the ACL logic. It is recommended to read the [Laminas ACL documentation](https://docs.laminas.dev/laminas-permissions-acl/) to learn more about how it all works.

There are 2 main concepts that must be managed, either from JSON config files or in the database (which works well with `locomotivemtl/charcoal-admin`), **roles** and **permissions**.

ACL Configuration
-----------------

[](#acl-configuration)

To set up ACL, it is highly recommended to use the `\Charcoal\User\Acl\Manager`.

ACL Example
-----------

[](#acl-example)

```
{
    "acl": {
        "permissions": {
            "superuser": {
                "superuser": true
            },
            "author": {
                "allowed": {},
                "denied": {}
            }
        }
    }
}
```

```
use Laminas\Permissions\Acl\Acl;
use Laminas\Permissions\Acl\Resource\GenericResource as AclResource;

// Dependencies from `charcoal-user`
use Charcoal\User\Acl\Manager as AclManager;

$acl = new Acl();

 // Add resource for ACL
$acl->addResource(new AclResource($resourceName));

$aclManager = new AclManager([
    'logger' => $logger,
]);
$aclManager->loadPermissions($acl, $config['acl.permissions'], $resourceName);

$authorizer = new Authorizer([
    'logger'   => $logger,
    'acl'      => $acl,
    'resource' => $resourceName,
]);

$isAllowed = $authorizer->userAllowed($user, [ 'permssion' ]);
```

Development
===========

[](#development)

To install the development environment:

```
★ composer install --prefer-source
```

To run the scripts (phplint, phpcs and phpunit):

```
★ composer test
```

API documentation
-----------------

[](#api-documentation)

- The auto-generated `phpDocumentor` API documentation is available at
- The auto-generated `apigen` API documentation is available at [https://codedoc.pub/locomotivemtl/charcoal-user/master/](https://codedoc.pub/locomotivemtl/charcoal-user/master/index.html)

Development dependencies
------------------------

[](#development-dependencies)

- `phpunit/phpunit`
- `squizlabs/php_codesniffer`
- `satooshi/php-coveralls`

Continuous Integration
----------------------

[](#continuous-integration)

ServiceBadgeDescription[Travis](https://travis-ci.org/locomotivemtl/charcoal-user)[![Build Status](https://camo.githubusercontent.com/2c180ebf0618bc3563d3b1c5111888e1c8f0a2f879a9d60a5c3802cde057992c/68747470733a2f2f7472617669732d63692e6f72672f6c6f636f6d6f746976656d746c2f63686172636f616c2d757365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/locomotivemtl/charcoal-user)Runs code sniff check and unit tests. Auto-generates API documentation.[Scrutinizer](https://scrutinizer-ci.com/g/locomotivemtl/charcoal-user/)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/318c58b6e6aa6e2aefc6ff805a6d0deca242b8916ba943faa68796fca1d686f8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c6f636f6d6f746976656d746c2f63686172636f616c2d757365722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/locomotivemtl/charcoal-user/?branch=master)Code quality checker. Also validates API documentation quality.[Coveralls](https://coveralls.io/github/locomotivemtl/charcoal-user)[![Coverage Status](https://camo.githubusercontent.com/8302dc6e58a8e1b1fcfb16465d2862a78f553b78a719eb3bea4386939954183d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6c6f636f6d6f746976656d746c2f63686172636f616c2d757365722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/locomotivemtl/charcoal-user?branch=master)Unit Tests code coverage.[Sensiolabs](https://insight.sensiolabs.com/projects/533b5796-7e69-42a7-a046-71342146308a)[![SensioLabsInsight](https://camo.githubusercontent.com/b4e01c929b8f64f8f85969cd6665ddcc34fa538082f991408b32ee6f1b86e15b/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35623035666164352d356532642d343164332d616364332d3132383232623335343839322f6d696e692e706e67)](https://insight.sensiolabs.com/projects/5b05fad5-5e2d-41d3-acd3-12822b354892)Another code quality checker, focused on PHP.Coding Style
------------

[](#coding-style)

The charcoal-user module follows the Charcoal coding-style:

- [*PSR-1*](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md)
- [*PSR-2*](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
- [*PSR-4*](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md), autoloading is therefore provided by *Composer*.
- [*phpDocumentor*](http://phpdoc.org/) comments.
- Read the [phpcs.xml](phpcs.xml) file for all the details on code style.

> Coding style validation / enforcement can be performed with `composer phpcs`. An auto-fixer is also available with `composer phpcbf`.

> This module should also throw no error when running `phpstan analyse -l7 src/` 👍.

Authors
=======

[](#authors)

- Mathieu Ducharme,
- Chauncey McAskill
- [Locomotive, a Montreal Web agency](https://locomotive.ca)

License
=======

[](#license)

Charcoal is licensed under the MIT license. See [LICENSE](LICENSE) for details.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 52.9% 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 ~58 days

Recently: every ~208 days

Total

34

Last Release

1519d ago

PHP version history (3 changes)0.1PHP &gt;=5.6.0

0.2.2PHP &gt;=5.6.0 || &gt;=7.0

0.6.4PHP &gt;7.1

### Community

Maintainers

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

---

Top Contributors

[![mcaskill](https://avatars.githubusercontent.com/u/29353?v=4)](https://github.com/mcaskill "mcaskill (64 commits)")[![mducharme](https://avatars.githubusercontent.com/u/12157?v=4)](https://github.com/mducharme "mducharme (39 commits)")[![dominiclord](https://avatars.githubusercontent.com/u/1775204?v=4)](https://github.com/dominiclord "dominiclord (8 commits)")[![JoelAlphonso](https://avatars.githubusercontent.com/u/10762266?v=4)](https://github.com/JoelAlphonso "JoelAlphonso (8 commits)")[![BeneRoch](https://avatars.githubusercontent.com/u/3017380?v=4)](https://github.com/BeneRoch "BeneRoch (2 commits)")

---

Tags

authenticationauthorizationcharcoalphpuser

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/locomotivemtl-charcoal-user/health.svg)

```
[![Health](https://phpackages.com/badges/locomotivemtl-charcoal-user/health.svg)](https://phpackages.com/packages/locomotivemtl-charcoal-user)
```

###  Alternatives

[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k373.5M3.3k](/packages/symfony-cache)[google/auth

Google Auth Library for PHP

1.4k294.2M219](/packages/google-auth)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k13.0M218](/packages/simplesamlphp-simplesamlphp)[simplesamlphp/saml2

SAML2 PHP library from SimpleSAMLphp

30418.0M43](/packages/simplesamlphp-saml2)[web-auth/webauthn-lib

FIDO2/Webauthn Support For PHP

12310.5M135](/packages/web-auth-webauthn-lib)

PHPackages © 2026

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