更新时间:2023-11-22 16:26:04
After more digging (read frantic googling), I found the problem and solution here
最重要的是,当站点A接受请求时,php会在http请求的整个长度内加载它的.env变量.在该请求期间,站点A调用站点B时,由于它们位于运行相同php的同一服务器上,因此php仍在使用站点A的.env,并且根本不会单独加载站点B的.env文件.
The bottom line, when site A accepts a request, php loads it's .env variables for the entire length of the http request. During that request, when site A calls site B, since they are on the same server running the same php, php is still using the .env from site A and does not separately load site B's .env file at all.
作者更好的解释:
创建带有变量的.env文件,这样人们就不会将其凭据推送到github存储库和其他可能共享源代码的地方.
The .env file with the variables was created so that people would not push their credentials to github repositories and other places where they may share the source.
现在,作为环境变量,它们在http请求的整个持续时间内(在本例中为脚本执行)在整个系统范围内.关键是您的脚本运行时间长.
Now, being environment variables they become system wide for the entire duration of the http request (in this case script execution). The point is that you got a long running script.
要找到确定的解决方案,您可以采用以下三种方法之一.
To find a definitive solution you could go one of the three ways.
....
命名空间" ENV变量.
'namespace' the ENV variables.