gpt4 book ai didi

laravel - 在 homestead.yaml 中设置特定于站点的服务器变量

转载 作者:行者123 更新时间:2023-12-02 16:30:00 26 4
gpt4 key购买 nike

我希望可以为特定站点设置服务器变量,在本例中为用于 Behat 验收测试的 URL。

我可以在 nginx 中手动设置它,例如:

fastcgi_param  APP_ENV  "acceptance";

但是,我想知道是否有一种方法可以在 homestead.yaml 中定义它,这样我就不必在每次配置时添加该行,或者同事是否需要在他们的计算机上进行设置。

我想做这样的事情:

sites:
- map: www.mysite.com
to: /home/vagrant/e247/nimble-admin/public
- map: www.mysite.test
to: /home/vagrant/e247/nimble-admin/public
variables:
- key: APP_ENV
value: acceptance

variables:
- key: APP_ENV
value: local

最佳答案

您完全可以按照上面的方式做到这一点。

从此页面:https://scotch.io/tutorials/getting-started-with-laravel-homestead#creating-environment-variables

At the bottom of your Homestead.yaml file, just add something like this:

variables:
- key: APP_DEBUG
value: true

如果您在 .env 文件中定义了这些值,请记住从其中删除或注释掉这些值,因为这将覆盖您在 homestead.yaml 中定义的内容

然后使用该值:

$app_env = getenv('APP_DEBUG'); // returns "true"

关于laravel - 在 homestead.yaml 中设置特定于站点的服务器变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26358011/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com