3

I am hoping I can set server variables for specific sites, in this case for a URL that is used for acceptance testing with Behat.

I can set this manually in nginx with e.g.:

fastcgi_param  APP_ENV  "acceptance";

However, I would like to know if there is a way of defining this in homestead.yaml so I don't have to add that line in each time I provision, or if a colleague needs to set up on their machine.

I would like to do something like:

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
Adamski
  • 3,585
  • 5
  • 42
  • 78

1 Answers1

0

You can do exactly that and in exactly the way that you have done it above.

From this page: 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

Remember to remove or comment out the values from your .env file if you have them defined there as that will overwrite what you define in your homestead.yaml

To then use that value:

$app_env = getenv('APP_DEBUG'); // returns "true"
Jonathan Irwin
  • 5,009
  • 2
  • 29
  • 48