-
-
Notifications
You must be signed in to change notification settings - Fork 207
Passthrough $_ENV variables to artisan commands #402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Legend. We were about to debug some issues related to this. @SRWieZ to the rescue right on time 💪🏻 |
Thanks so much for this PR @SRWieZ. I was experiencing some issues related to this last week concerning Custom Events dispatched from a artisan command child process. Blocked this evening to get into the weeds but here you came along and found the issue 🥇 Absolutely stellar. Simon and I had a little back & forth about it. Two takeaways:
I think after some digging only these are absolutely nessecary:
Arguably we'll need these too (though I'm not 100% certain about that, needs checking)
Would you be willing to add this to your PR? 🙏🏻 |
100% we'll need |
Thank you for your kind words, @gwleuverink! Yeah, I took a shortcut with We can limit it to
Let's make it even better. What do you think about creating an endpoint for launching PHP processes (@simonhamp and @gwleuverink ) ? |
Oh, there is a function called getDefaultEnvironmentVariables. I wonder why the I don't see any valid reason. |
You're right. It seems like we can get these variables & mix them in the electron-plugin I thought the secret wouldn't be available there, but it is. In the
Peculiar indeed. In the |
Forget I said this. Just noticed the queue isn't started using the native |
@gwleuverink tl;dr: on balance, yes, I think we should remove it. #346 references using the I don't think it make sense to have this as a separate command that is callable in this way. It tries to set up the context as if the NativePHP application (and thus the Electron environment) is running, but there are no guarantees that it is. |
@simonhamp, what do you think about my proposal? That will be summarised by:
I can do it all in the Laravel part, but I think it makes more sense that it should be handled by the Electron part. Bonus:
|
👍🏼 Yep, I like it, especially that it's mostly taking place within the Electron plugin... this keeps the Laravel side clean and clear. It also keeps all of those environment variables that are defined by the environment (in this case, Electron), contained within the environment, rather than relying on them being passed backwards and forwards between Electron and Laravel. I think it will be slightly more performant and reliable this way. |
Shoot I missed your convo here. I was tinkering around & PR'd a fix on the electron repo: NativePHP/electron#129 This approach still forwards those variables to every child process (not artisan only like before). If you guys think it's worth it we can do that separate endpoint. There are so little variables forwarded that I'm starting to doubt if it's worth a separate endpoint though. What do you think? |
I was checking if it worked from the electron side and figured I'd just PR it. Hope I didn't get in the way with something you were working on @SRWieZ. Would love feedback if you have it! |
Should we close this PR and move the convo over to the electron one? |
The problem
I got an artisan command that sends notifications
NativeAppServiceProvider.php
app:forge-checker artisan command
Current solution
A simple fix is to pass nativephp env variables like this.
Proposed solution
I would like to argue that
ChildProcess::artisan()
should pass through those variables by default.I think it's expected that everything we write in the Laravel part should just work.
That's why I didn't pass $_ENV in
php()
orstart()
functions by default, only inartisan()