-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
| PHP |
^8.1 (tested on 8.1 – 8.4) |
| Core extensions | None |
| Adapter extensions | Depends on the adapter you choose — see below |
The package core has zero runtime dependencies. Each adapter only needs its own backend extension, and only when you actually use it.
composer require initphp/sessionsClasses are autoloaded under the InitPHP\Sessions namespace via PSR-4:
{
"autoload": {
"psr-4": {
"InitPHP\\Sessions\\": "src/"
}
}
}Install only what the adapter you pick needs:
| Adapter | Needs |
|---|---|
| File | Nothing extra |
| Redis | ext-redis |
| PDO |
ext-pdo + a driver (pdo_mysql, pdo_pgsql, pdo_sqlite, …) |
| Cookie |
composer require initphp/encryption + ext-openssl
|
| Memcache / Memcached |
ext-memcached (preferred) or ext-memcache
|
| MongoDB | ext-mongodb |
These are declared as suggest entries in composer.json, so Composer reminds
you about them but never forces them on.
<?php
require __DIR__ . '/vendor/autoload.php';
use InitPHP\Sessions\Session;
Session::createImmutable()->start();
Session::set('hello', 'world');
echo Session::get('hello'); // worldIf the autoloader cannot find the class, re-run composer dump-autoload and make
sure your script requires vendor/autoload.php before using Session.
Every pull request runs the test matrix against:
- PHP 8.1 (also with lowest dependencies)
- PHP 8.2
- PHP 8.3
- PHP 8.4
Static analysis (PHPStan level 8) and coding-style (PSR-12) checks run on every
PR as well. If you hit a regression on a supported version, please
file an issue and include the
output of php -v.
- Take the five-minute tour in Quick Start.
- Understand the design in The Session Facade.
- Pick a backend in Adapters.
initphp/sessions · MIT License · part of the InitPHP family
Source · Issues · Discussions · Packagist · Contributing · Security Policy
Getting Started
Core Usage
Adapters
- Adapters Overview
- File Adapter
- Redis Adapter
- PDO Adapter
- Cookie Adapter
- Memcache / Memcached Adapter
- MongoDB Adapter
- Custom Adapters
Reference
Practical Guides
Migration & Help