PHPackages                             sulaco-tech/psr7-sessions - 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. sulaco-tech/psr7-sessions

ActiveLibrary

sulaco-tech/psr7-sessions
=========================

Implementation of a PSR-7 and PSR-15 compatible middleware that enables sessions in PSR-7 based applications.

1.0.0(6y ago)017MITPHPPHP ^7.0

Since Mar 23Pushed 6y ago1 watchersCompare

[ Source](https://github.com/sulaco-tech/psr7-sessions-php)[ Packagist](https://packagist.org/packages/sulaco-tech/psr7-sessions)[ RSS](/packages/sulaco-tech-psr7-sessions/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

psr7-sessions-php
=================

[](#psr7-sessions-php)

Implementation of a PSR-7 and PSR-15 compatible middleware that enables sessions in PSR-7 based applications.

Install
-------

[](#install)

Install with [composer](https://getcomposer.org/).

```
$ composer require sulaco-tech/psr7-sessions
```

Requirements
------------

[](#requirements)

This branch requires PHP 7.0 or up with built-in extensions:

- JSON
- PCRE

Followed packages are required too:

- [`sulaco-tech/base58`](https://github.com/sulaco-tech/base58-php)

Usage
-----

[](#usage)

You can use the `SulacoTech\PSR7Sessions\SessionMiddleware` in any PSR-15 compatible middleware.

In a [`slim/slim`](https://github.com/slimphp/Slim) application, this would look like following:

```
use \Slim\Factory\AppFactory;
use \Psr\Http\Message\ResponseInterface as Response;
use \Psr\Http\Message\ServerRequestInterface as Request;
use \SulacoTech\PSR7Sessions\SessionMiddleware;
use \SulacoTech\PSR7Sessions\SessionFileStorage;
use \SulacoTech\PSR7Sessions\SessionFileStorageConfiguration;

// create application
$app = AppFactory::create();

// prepare configuration
$sessionsDirectory = __DIR__ . '/../tmp/sessions';
$sessionName = 'example';
$sessionsExpirationTime = 300; // in seconds
$config = new SessionFileStorageConfiguration($sessionsDirectory, $sessionName, $sessionsExpirationTime);

// create storage with some configuration
$sessionStorage = new SessionFileStorage($config);

// call garbage collector
$sessionStorage->gc();

// create and add middleware
$app->add(new SessionMiddleware($sessionStorage));

// basic example
$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {

	// get session
	$session = $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE);

	// read and update session's data
	$counter = $session->get('counter', 0);
	$session->set('counter', ++ $counter);

	// same instructions using array access style
	//$counter = $session['counter'] ?? 0;
	//$session['counter'] = ++ $counter;

	// make a response
	$response->getBody()->write("Hello, {$args['name']}! This page is visited $counter times.");

	return $response;
});

// run application
$app->run();
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2240d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/61331007?v=4)[sulaco-tech](/maintainers/sulaco-tech)[@sulaco-tech](https://github.com/sulaco-tech)

---

Top Contributors

[![sulaco-tech](https://avatars.githubusercontent.com/u/61331007?v=4)](https://github.com/sulaco-tech "sulaco-tech (10 commits)")

---

Tags

psr7sessionpsr15

### Embed Badge

![Health badge](/badges/sulaco-tech-psr7-sessions/health.svg)

```
[![Health](https://phpackages.com/badges/sulaco-tech-psr7-sessions/health.svg)](https://phpackages.com/packages/sulaco-tech-psr7-sessions)
```

###  Alternatives

[league/route

Fast routing and dispatch component including PSR-15 middleware, built on top of FastRoute.

6633.1M116](/packages/league-route)[compwright/php-session

Standalone session implementation that does not rely on the PHP session module or the $\_SESSION global, ideal for ReactPHP applications

189.4k](/packages/compwright-php-session)[samsonasik/error-hero-module

A Hero for your Laminas and Mezzio application to trap php errors &amp; exceptions

5233.4k1](/packages/samsonasik-error-hero-module)[wellrested/wellrested

Simple PHP Library for RESTful APIs

4818.7k4](/packages/wellrested-wellrested)[phps-cans/psr7-middleware-graphql

This package contains a http-interop middleware implementation to handle graphql request

1528.7k](/packages/phps-cans-psr7-middleware-graphql)[prooph/http-middleware

http middleware for prooph components

1145.0k](/packages/prooph-http-middleware)

PHPackages © 2026

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