Download the PHP package eril/auth without Composer
On this page you can find all versions of the php package eril/auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package auth
Short Description Simple PHP authentication and authorization library with sessions, remember-me and role based permissions.
License MIT
Informations about the package auth
Eril Auth
Lightweight authentication and authorization library for modern PHP applications.
Eril Auth provides session-based authentication, persistent login (Remember Me), role-based authorization (RBAC), login rate limiting, provider login, user profiles and diagnostics without requiring a framework.
Features
- Session-based authentication
- Multiple login fields (email, username, phone, etc.)
- Persistent login (Remember Me)
- Login rate limiting
- Login with external providers
- Role-based authorization (RBAC)
- Wildcard permissions
- User profiles
- Authentication diagnostics
- Configuration publisher
- CLI installer
- Framework agnostic
- PHP 8.1+
Requirements
- PHP 8.1+
- PDO Extension
Installation
Install via Composer:
Generate the default configuration:
Or publish only the configuration files:
Verify your installation:
Quick Start
Load the configuration during application bootstrap.
This automatically creates:
Authenticate a user:
Configuration
The installer generates a complete config/auth.php file with documentation for every available option.
A minimal configuration looks like this:
The generated configuration file contains additional options for:
- Session handling
- User table mapping
- Rate limiting
- Remember Me
- Profiles
- Provider login
Authentication
Login
Authenticate using the configured login field(s).
If multiple login fields are configured:
The following will all work:
Manual Login
You may authenticate a user manually.
This is useful when authentication is handled by another system.
Login with Provider
Eril Auth supports authentication through externally validated identity providers.
Typical flow:
Example:
Eril Auth does not implement OAuth.
Token validation must be performed by your application or an OAuth library before calling
loginWithProvider().
Remember Me
Enable persistent login:
After a successful login:
On future visits, Eril Auth automatically restores the session if the remember cookie is valid.
Database
Remember Me requires two nullable columns in the users table.
Login Rate Limiting
Protect login attempts against brute-force attacks.
Available key strategies:
| Strategy | Description |
|---|---|
| login | Limit by login value |
| ip | Limit by client IP |
| login_ip | Limit by login + IP |
Logout
Authentication State
Determine whether a user is authenticated.
Or check if no user is authenticated.
Current User
Retrieve the authenticated user.
Retrieve the authenticated user's identifier.
Retrieve the authenticated user's profile.
AuthUser
AuthUser represents the currently authenticated user.
It provides convenient methods for accessing user data, checking roles and permissions, and loading the associated profile.
Standard Methods
Role Checks
Equivalent using the facade:
Permission Checks
Equivalent:
Dynamic Properties
Every column from the original database row remains available.
Array Access
AuthUser implements ArrayAccess.
Utility Methods
Convert the authenticated user to an array.
Select only specific fields.
Exclude fields.
Access the original database row.
Profiles
Many applications store additional information in separate profile tables.
Example:
Configure the relationship:
Retrieve the authenticated profile:
or
Access profile data:
Profiles are loaded lazily and remain independent from AuthUser.
This avoids unnecessary database queries and keeps authentication data separate from domain-specific information.
Authorization (RBAC)
Permissions are configured per role.
Example:
basically:
Checking Permissions
Negated check:
Require a permission:
If authorization fails, an AuthorizationException is thrown.
Wildcards
Grant every permission:
Grant every permission within a namespace:
Which automatically matches:
Diagnostics
Inspect the current authentication configuration.
Typical output:
The diagnostic tool validates:
- Database connection
- User table
- User columns
- Session configuration
- Remember Me columns
- Provider tables
- Profile mappings
- Permission configuration
Exceptions
Eril Auth provides dedicated exceptions.
Example:
API Reference
Configuration
Authentication
Current User
Roles
Permissions
Utilities
Out of Scope
Eril Auth intentionally focuses on session-based authentication and authorization.
The following features are intentionally not included:
- User registration
- Password reset
- Email verification
- OAuth flows
- JWT authentication
- WebAuthn / Passkeys
- Multi-factor authentication (MFA/TOTP)
- ORM integration
These features are better implemented by your application or by dedicated libraries.
License
Licensed under the MIT License.
All versions of auth with dependencies
ext-pdo Version *