PHPackages                             logifire/nano-php-state - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. logifire/nano-php-state

ActiveLibrary[HTTP &amp; Networking](/categories/http)

logifire/nano-php-state
=======================

Session and cookie handling

0.2.0(7y ago)02MITPHPPHP ^7.2

Since Feb 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Logifire/nano-php-state)[ Packagist](https://packagist.org/packages/logifire/nano-php-state)[ RSS](/packages/logifire-nano-php-state/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (8)Versions (4)Used By (0)

nano-php-state
==============

[](#nano-php-state)

The purpose of this library is to bridge the PHP session implementation, and the PSR 7, 15 standards.

Add the `PhpStateMiddleware` to your middleware stack, and use the `SessionService` to start a new session instead of `session_start()`.

You can optionally use the `SessionCollection` instead of `$_SESSION`.

```
...
/* @var ServerRequestInterface $server_request */
$session_service = new SessionService($server_request);

// Starts a writable session, this is the default you are used to when calling session_start()
$session_service->startWriteRead();

// Now you can use sessions
$_SESSION['content'] = 'Hello World';

// Alternative
$session_collection = new SessionCollection();
$session_collection->setString('content', 'Hello World');
...

```

Cookie abstraction
------------------

[](#cookie-abstraction)

This library also comes with a cookie abstraction, if you need to set custom cookies.

```
...
// The PhpStateMiddleware has an implicit dependency on ResponseCookieService, must be the same instance past though the app
$response_cookie_service = new ResponseCookieService();
...
$cookie = new ResponseCookie('name', 'value');
$cookie->setExpires(strtotime('+ 14 days'));

$response_cookie_service->addCookie($cookie);
...

```

---

***NOTE***There is no implementation of the `cache_limit` option. You should, however, be able to use most of the session options.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Every ~8 days

Total

3

Last Release

2615d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16954276?v=4)[Bo Andersen](/maintainers/Logifire)[@Logifire](https://github.com/Logifire)

---

Top Contributors

[![Logifire](https://avatars.githubusercontent.com/u/16954276?v=4)](https://github.com/Logifire "Logifire (24 commits)")

---

Tags

psr-7middlewarepsr-15session

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/logifire-nano-php-state/health.svg)

```
[![Health](https://phpackages.com/badges/logifire-nano-php-state/health.svg)](https://phpackages.com/packages/logifire-nano-php-state)
```

###  Alternatives

[mezzio/mezzio

PSR-15 Middleware Microframework

3883.6M97](/packages/mezzio-mezzio)[tuupola/slim-basic-auth

PSR-7 and PSR-15 HTTP Basic Authentication Middleware

4442.0M25](/packages/tuupola-slim-basic-auth)[relay/relay

A PSR-15 server request handler.

3302.1M85](/packages/relay-relay)[tuupola/cors-middleware

PSR-7 and PSR-15 CORS middleware

1331.8M24](/packages/tuupola-cors-middleware)[laminas/laminas-stratigility

PSR-7 middleware foundation for building and dispatching middleware pipelines

586.6M81](/packages/laminas-laminas-stratigility)[middlewares/utils

Common utils for PSR-15 middleware packages

503.4M93](/packages/middlewares-utils)

PHPackages © 2026

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