{"id":18821155,"url":"https://github.com/compwright/php-session","last_synced_at":"2026-03-16T07:02:12.333Z","repository":{"id":56957084,"uuid":"399097474","full_name":"compwright/php-session","owner":"compwright","description":"Standalone session implementation that does not rely on the PHP session module or the $_SESSION global, ideal for Swoole or ReactPHP applications","archived":false,"fork":false,"pushed_at":"2025-01-13T18:34:36.000Z","size":245,"stargazers_count":17,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T14:47:42.678Z","etag":null,"topics":["psr-15","psr-7","react-php","reactphp","sessions","swoole"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/compwright/php-session","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/compwright.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["compwright"]}},"created_at":"2021-08-23T12:35:21.000Z","updated_at":"2025-01-13T18:35:56.000Z","dependencies_parsed_at":"2024-11-08T00:35:00.644Z","dependency_job_id":"c4633dbf-ea47-4159-876e-2906820ebdbc","html_url":"https://github.com/compwright/php-session","commit_stats":{"total_commits":55,"total_committers":5,"mean_commits":11.0,"dds":0.2909090909090909,"last_synced_commit":"8ec48a534ef7b9c5178a85492d4d95a87c493bb0"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compwright%2Fphp-session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compwright%2Fphp-session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compwright%2Fphp-session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compwright%2Fphp-session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/compwright","download_url":"https://codeload.github.com/compwright/php-session/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248615138,"owners_count":21133833,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["psr-15","psr-7","react-php","reactphp","sessions","swoole"],"created_at":"2024-11-08T00:34:47.160Z","updated_at":"2026-03-16T07:02:07.282Z","avatar_url":"https://github.com/compwright.png","language":"PHP","readme":"# Compwright\\PhpSession\n\nA PHP session implementation that is single-process safe, compatible with PSR-7 and PSR-15, and\ndoes not rely on global variables ($_SESSION, $_COOKIE, etc).\n\nThis implementation is patterned after the built-in PHP session library, but is not a drop-in\nreplacement for it. This library differs from the PHP session library in the following ways:\n\n* Requires PHP 8+\n* Fully object-oriented\n* Strict mode is always on and cannot be disabled\n* Auto-start and auto-shutdown are not supported\n* Reading/writing cookie and cache headers is handled in middleware (included)\n* Handlers implement the built-in PHP SessionHandlerInterface, but the PHP SessionHandler class\n  will not work because it depends internally on the PHP session extension\n* Session data is accessed using a Session object, not via $_SESSION\n\nThis library is ideal for single-process event loop-driven applications, using servers like\n[ReactPHP](https://reactphp.org).\n\n## Supported Features\n\n* [Array or Object Access](features/access.feature)\n* [Collision-Proof Secure ID Generation](features/id.feature)\n* [Data Persistance](features/persistence.feature)\n* [ID Regeneration](features/regeneration.feature)\n* [Lockless Concurrency](features/concurrency.feature)\n* [Garbage Collection](features/gc.feature)\n\n## Installation\n\n    composer require compwright/php-session\n\n## Examples\n\n### Slim Framework\n\nSee [tests/integration/server/App](tests/integration/server/App)\n\nTo run with PHP Development Server:\n\n    $ composer run-script start-php\n\n### Basic Usage\n\n```php\n$sessionFactory = new Compwright\\PhpSession\\Factory();\n\n$manager = $sessionFactory-\u003epsr16Session(\n    /**\n     * @param Psr\\SimpleCache\\CacheInterface\n     */\n    $cache,\n\n    /**\n     * @param array|Compwright\\PhpSession\\Config\n     */\n    [\n        'name' =\u003e 'my_app',\n        'sid_length' =\u003e 48,\n        'sid_bits_per_character' =\u003e 5,\n    ]\n);\n\n// Start the session\n$manager-\u003eid($sid); // Read $sid from request\n$started = $manager-\u003estart();\nif ($started === false) {\n    throw new RuntimeException(\"The session failed to start\");\n}\n\n// Read/write the current session\n$session = $manager-\u003egetCurrentSession();\n$session[\"foo\"] = \"bar\";\nunset($session[\"bar\"]);\n\n// Save and close the session\n$ended = $manager-\u003ewrite_close();\nif ($ended === false) {\n    throw new RuntimeException(\"The session failed to close properly, data may have been lost\");\n}\n```\n\n## License\n\n[MIT License](LICENSE)\n","funding_links":["https://github.com/sponsors/compwright"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompwright%2Fphp-session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompwright%2Fphp-session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompwright%2Fphp-session/lists"}