Laravel Octane and Shared Static Properties between Request Cycles #47958
-
Question: My question is: How does Laravel Octane handle request serving for individual request cycles, and why is the static property value shared across different requests? Is there a recommended approach to avoid such shared state-related issues while using Laravel Octane? Any insights, best practices, or workarounds would be greatly appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
You should read https://redberry.international/what-is-octane-in-laravel-things-to-know/ Have you tried storing it in a session? |
Beta Was this translation helpful? Give feedback.
I wanted to keep this discussion active, as others might encounter the same issue. To prevent static property data sharing, I used an event to clear the data. In the
octane.php
configuration file, there's alisteners
array where you can add your own listener under theRequestReceived::class
key. This event triggers when the application receives a request, allowing us to clear the data at the start of each request cycle.