CRUD
CRUD copied to clipboard
Update Backpack to work with Octane.
WHY
BEFORE - What was wrong? What was happening before this PR?
1 - Error reported in https://github.com/Laravel-Backpack/CRUD/issues/4536 . The error was due to the fact that for Backpack to work with Octane we needed to change the CrudPanel binding from singleton to scoped (that forces the CrudPanel to be destroyed at the end of each request, but still a "singleton" during the whole request). Since CrudPanel gets destroyed, but Octane does not fully rebuild the application, the configs pushed from other packages ServiceProviders didn't get re-added into CrudPanel object.
2 - CrudPanel binded as singleton
instead of scoped
Like I said before, our usecase is that the CrudPanel
should be a singleton during the WHOLE request, but at the end of the request it should be destroyed.
A new request will be initiated from Backpack Admin Panel and we would build the CrudPanel all over again (as expected).
With Octane in play, if CrudPanel
is registered as a singleton
, it will never be destroyed, and you will get errors like Cannot add a filter with the same name
, even if navigating different CrudControllers, because the CrudPanel is persisted in memory.
For us "mortals" (not octanized), CrudPanel still a single during the whole request as it was previously.
3 - The ViewNamespaces
implementation in general, preventing Backpack to work with Octane
Since this view namespaces can be added from anywhere in the app, and since octane does not rebuild the whole app, when destroying the crud at the end of the request the added view namespaces were lost.
AFTER - What is happening after this PR?
CrudPanelViewNamespaces are a singleton class in the app, so it holds, continuously, the namespaces added from anywhere in the app.
There is a octane compatibility Larastan rule which you all might want to run. It's in my earlier larastan PR, but not sure how smart that rule is in detecting octane compatibility issues but worth a try
Is it merged with latest version 5.3.0 ? Or should keep to use this branch to able to use octane?
just curious @masrodjie by your comment, does it mean you are running this branch in production now?
@ziming sorry wrong place. I should commented on here https://github.com/Laravel-Backpack/CRUD/issues/4536 I am using this branch to running octane (swoole) well backpack/crud:"dev-singleton-view-namespaces as 5.2.99" Backpack version 5.2 not work with octane
Hello @masrodjie
I've merged main branch here.
Thanks for your patience, on this one, we are working on it!
Cheers