404labfr / 404labfr/laravel-impersonate

Laravel Octane support

未關閉
#164 4 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
PHP
星號
2.3k
分支
235
PR 合併指標
30 天內沒有已合併 PR

描述

Laravel Impersonate does not work with Laravel Octane. This manifests as several different errors concerning the `$app` container missing expected values when impersonating and leaving impersonation, from both the `ImpersonateManager` and `ImpersonateController`.

I'm seeing two points where this is an issue:

1. The singleton in the `ImpersonateServiceProvider` has the app container passed to the constructor. [This doesn't work in the Octane paradigm](https://laravel.com/docs/9.x/octane#container-injection) -- the container is adjusted for every request, so a fresh copy is needed.
- I'm not sure if the singleton is strictly needed? I've worked around this by extending the service provider and reimplementing `register()` without that.
1. The constructor in `ImpersonateController` sets the `manager` property. It seems like the constructors for controllers are only called once when Octane boots, which is leading to the app container inside that manager instance being stale.
- Injecting it into the take/leave methods individually instead of setting it in the constructor should avoid the issue.

If you are open to a PR, I would be happy to send one.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。