yakeing/php_session
yakeing/php_session is a lightweight PHP session management package with a simple API for starting sessions, reading and writing session data, and handling session lifecycle. It provides a straightforward way to add session support to PHP applications with minimal overhead.
This is a small, framework-agnostic wrapper around PHP's native $_SESSION — not a Laravel package. There is no service provider, no config file to publish, and no Laravel integration of any kind. Before installing anything, be clear about why you're reaching for it: inside a normal Laravel HTTP request, Illuminate\Session already does everything this class does, with encryption, CSRF, flash data, and a tested driver abstraction. This package earns its place in narrow cases: a legacy PHP script being dropped into public/, a standalone endpoint that boots without the framework, or a migration where you're trying to keep an old call site alive while you rewrite it.
The practical first steps:
composer.json and commit composer.lock — there will be no upstream fixes.src/ before the README. The entire surface area is a handful of methods (start, set, get, delete, destroy, and usually an exists/clear pair), and the source is short enough to audit in one sitting. Confirm the exact method names and whether they're static or instance methods — the README examples are the only documentation you get, and they may not match the current tag.start() before any output, then set()/get() with plain string keys.Your first use case should be the smallest possible one: a single legacy script that needs to persist a user preference or a cart fragment across two requests. Get that working in isolation, outside the framework, before you try to wire it into a Laravel route.
Legacy bridge inside a Laravel app. The cleanest pattern is to keep the package entirely outside the framework's request lifecycle. Put the legacy entry point in public/legacy/checkout.php, let it require the Composer autoloader directly, and never route it through Laravel's HTTP kernel. Laravel's StartSession middleware will not run, so there is no contention over the session ID and no double session_start().
Adapter behind an interface. If the package is temporary scaffolding, wrap it immediately:
interface SessionStore {
public function get(string $key, $default = null);
public function put(string $key, $value): void;
public function forget(string $key): void;
}
final class LegacySessionStore implements SessionStore { /* delegates to the package */ }
Bind the interface in a service provider and resolve it in your controllers. When you're ready, swap the binding for a thin wrapper over Illuminate\Session\Store and delete the dependency. This is the single highest-value pattern here, because it turns an archived dependency into a one-line change later.
CLI and queue workers. Long-running processes have no HTTP session, and this package is a reasonable lightweight key-value store for them if you treat $_SESSION as a plain array — though Illuminate\Cache's array or file store is usually the better answer. Use it here only if you're already carrying the dependency.
Configuration before start. Whatever cookie name, lifetime, and save path the class exposes must be set before start(). Treat construction-plus-start as one atomic step in a factory method so nobody can call set() on an unstarted session.
Testing. Because state lives in the superglobal, reset it in setUp(): clear $_SESSION, call session_destroy() if a session is active, and reset session_status(). Don't rely on process isolation alone — PHPUnit will leak state between tests otherwise.
session_start() return values that are ignored. Run it once under your target PHP version with E_ALL before trusting it.start() will either warn, silently no-op, or — worse — reset the session array. Never use both in the same request.start() kills the Set-Cookie header. Laravel's response pipeline has already flushed headers by the time a view renders, so package calls from Blade or a controller action are effectively broken.session_regenerate_id() on privilege change. Do it yourself at login, or you've shipped a vulnerability.$_SESSION['cart'] via the package and read session('cart') via Laravel for the same key, you'll get inconsistent results depending on driver and cookie encryption. Pick one owner per key.session_set_cookie_params and session_name must precede session_start(). Check the constructor for anything that sets these too late.composer.json; older packages sometimes ship a class name that doesn't match the filename, which breaks case-sensitive filesystems but works on macOS.session_status(), headers_sent($file, $line), session_name(), session_save_path(), and whether the cookie actually appears in the browser devtools. Nine times out of ten the problem is one of those five.How can I help you explore Laravel packages today?