element / sentinel
Sentinel is a PHP 7.4+ framework agnostic fully-featured authentication & authorization system. It also provides additional features such as user roles and additional security features.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/element/sentinel
Requires
- php: >=7.2
- ext-pdo: *
- ext-pdo_mysql: *
- monolog/monolog: ^2.11
- psr/log: ^1.1 || ^2.0 || ^3.0
Requires (Dev)
- phpunit/phpunit: ^9.6
Suggests
- illuminate/database: Required if you want to use the Eloquent repository adapter
- php8: This package utilizes features that are found in 7.4 - But if you use php8 or higher, then you should have no problems
This package is auto-updated.
Last update: 2026-02-22 08:51:34 UTC
README
A framework‑agnostic authentication & activation library for PHP 7+
Element Sentinel is a simple, stable and flexible authentication component designed to work in any PHP 7.x project — including custom frameworks such as Element3.
The library provides:
- User activation through activation codes
- Repository implementations for PDO and Eloquent
- A clean and minimal Sentinel core for activation, hashing, and storage
- Plain SQL migration files (no dependency on Laravel migrations)
- A fully framework‑agnostic architecture (no routing, middleware, etc.)
The goal is to deliver a minimalistic yet robust authentication component that is easy to integrate without forcing any particular structure or framework.
🚀 Installation
Install via Composer:
composer require element/sentinel
🧩 Instantiating Sentinel
Element Sentinel is instantiated through a fluent builder, allowing you to plug in your preferred storage layer (PDO or Eloquent) as well as the password hasher. This makes Sentinel fully flexible and framework‑agnostic. Below are two recommended setups.
🔌 Using PDO
use PDO; use Element\Sentinel\SentinelBuilder; use Element\Sentinel\Support\NativePasswordHasher; use Element\Sentinel\Infrastructure\PDO\PdoUserRepository; use Element\Sentinel\Infrastructure\PDO\PdoActivationRepository; $pdoConnection = new PDO( 'mysql:host=localhost;dbname=myapp;charset=utf8mb4', 'username', 'password', [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ] ); $sentinel = Builder::create() ->withUserRepository(new PdoUserRepository($pdoConnection)) ->withActivationRepository(new PdoActivationRepository($pdoConnection)) ->withPasswordHasher(new NativePasswordHasher()) ->build();
or by
🏗 Using Eloquent (Capsule)
use Illuminate\Database\Capsule\Manager as Capsule; use Element\Sentinel\SentinelBuilder; use Element\Sentinel\Support\NativePasswordHasher; use Element\Sentinel\Infrastructure\Eloquent\EloquentUserRepository; use Element\Sentinel\Infrastructure\Eloquent\EloquentActivationRepository; $capsule = new Capsule(); $capsule->addConnection([ 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'myapp', 'username' => 'username', 'password' => 'password', ]); $capsule->setAsGlobal(); $capsule->bootEloquent(); $sentinel = Builder::create() ->withUserRepository(new EloquentUserRepository()) ->withActivationRepository(new EloquentActivationRepository()) ->withPasswordHasher(new NativePasswordHasher()) ->build();