定制 element/sentinel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

element/sentinel

最新稳定版本:3.0.3

Composer 安装命令:

composer require 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.

README 文档

README

A framework‑agnostic authentication & activation library for PHP 7+

Packagist Version Total Downloads PHP Version License

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',
    'schemas'  => 'myapp',
    'username'  => 'username',
    'password'  => 'password',
]);

$capsule->setAsGlobal();
$capsule->bootEloquent();

$sentinel = Builder::create()
    ->withUserRepository(new EloquentUserRepository())
    ->withActivationRepository(new EloquentActivationRepository())
    ->withPasswordHasher(new NativePasswordHasher())
    ->build();

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固