Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Flush On Kernel Terminate Bundle

Flush On Kernel Terminate Bundle Laravel Package

alcalyn/flush-on-kernel-terminate-bundle

View on GitHub
Deep Wiki
Context7

Just add a listener to automatically flush non-flushed entities after the response has been sent.

Frequently asked questions about Flush On Kernel Terminate Bundle
Can I use this package directly in Laravel 8/9/10 without modifications?
No, this package is designed for Symfony2 and won’t work out-of-the-box in Laravel. Laravel’s kernel lifecycle and Doctrine integration differ significantly from Symfony’s. You’d need to rewrite it as a Laravel middleware or service provider.
How can I replicate this bundle’s functionality in Laravel?
Create a custom middleware that hooks into Laravel’s `terminate` method. Inject the Doctrine `EntityManager` and call `flush()` when the request ends. This avoids the Symfony dependency while achieving the same goal.
Does this package support Doctrine ORM v3+ (used in Laravel) or only v2.x?
The original bundle targets Doctrine ORM v2.x (Symfony2). Laravel typically uses v3+, so you’d need to verify API compatibility or adapt the logic for newer Doctrine versions, especially if relying on internal entity state tracking.
Will this work for CLI commands or only HTTP requests?
The Symfony2 bundle focuses on HTTP responses via `KernelTerminate`. In Laravel, CLI commands don’t trigger the same lifecycle. You’d need to manually flush in CLI contexts or use Laravel’s `commands.terminating` event for consistency.
Are there performance risks to flushing entities after the response is sent?
Flushing after response can delay request completion, but it prevents memory leaks from unflushed entities. For performance-critical apps, consider queueing flushes (e.g., via Laravel Queues) instead of blocking the HTTP response.
Does this package handle transactions or rollbacks correctly?
The original bundle doesn’t explicitly address transactions. In Laravel, flushing after response might commit transactions prematurely. Test thoroughly in your environment, especially for long-running requests with deferred writes.
Is there a Laravel-native alternative to this package?
Yes. Use Laravel’s `terminate` middleware or register a service provider to flush entities. For Doctrine, leverage `doctrine/orm` events like `onFlush` or `postFlush` for granular control without Symfony dependencies.
How do I ensure only 'non-flushed entities' are targeted, like the Symfony bundle?
The Symfony bundle relies on Symfony-specific entity state tracking. In Laravel, you’d need to manually track flushed entities (e.g., via a service container singleton) or use Doctrine’s `UnitOfWork` to identify pending changes before flushing.
Will this package work with Laravel’s queue system for deferred flushes?
No, this package is designed for immediate post-response flushes. For queue-based deferred flushes, dispatch a job (e.g., `flush-entities`) after the request ends, then process it asynchronously using Laravel Queues.
What Laravel versions and PHP versions does this package support?
The original package requires PHP ≥5.3.2 and Symfony2. Laravel 8+ requires PHP ≥7.3, and the package isn’t tested for Laravel compatibility. A custom rewrite would need to align with your Laravel/PHP version.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route