Modern Laravel applications increasingly run on long-lived application runtimes such as:
- Laravel Octane (powered by Swoole or RoadRunner)
- FrankenPHP (Worker Mode)
- Swoole / OpenSwoole
In these environments, the PHP application boots once into memory and handles thousands of subsequent HTTP requests in a persistent loop.
In traditional PHP-FPM, PHP processes shut down completely after every request, resetting all globals and singletons.
In worker-mode runtimes (like Octane), standard container singletons ($app->singleton()) persist across requests. If a package stores request-specific metadata (such as page titles, descriptions, or user-specific OG tags) on a persistent singleton, that metadata will leak across requests to other users.
SeoKit is engineered specifically for modern Laravel environments.
In SeoKitServiceProvider, SeoKit registers SeoKitManager using Laravel's request-scoped binding:
$this->app->scoped(SeoKitManager::class, fn (): SeoKitManager => new SeoKitManager(
new MetaTags,
new OpenGraph,
new TwitterCards,
new JsonLD
));- Fresh Per Request: For every incoming HTTP request, Laravel resolves a new, isolated instance of
SeoKitManager. - Zero Cross-Request Contamination: Metadata, titles, images, and JSON-LD schemas set during one request can never leak into another.
- Automatic Cleanup: At the end of the HTTP request lifecycle, the container flushes the scoped instance, freeing memory and eliminating memory leaks.
- Zero Configuration Needed: You do not need to register any listeners in
config/octane.phpflusharrays. SeoKit works out-of-the-box.