无法在Laravel Homestead配置中设置多个环境变量

时间:2015-01-02 19:20:01

标签: laravel environment-variables vagrant homestead

我的yaml文件如下所示:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/VagrantSites/project-base
      to: /home/vagrant/sites/project-base
    - map: ~/VagrantSites/craft-base
      to: /home/vagrant/sites/craft-base

sites:
    - map: local.project-base
      to: /home/vagrant/sites/project-base/public_html
    - map: craft.dev
      to: /home/vagrant/sites/craft-base/public_html

databases:
    - homestead

variables:
    - key: APP_ENV
      value: local
    - key: APP_DEV_MODE
      value: true
    - key: APP_DB_SERVER
      value: localhost
    - key: APP_DB_DATABASE
      value: craft_base
    - key: APP_DB_USER
      value: homestead
    - key: APP_DB_PASSWORD
      value: secret

大概是因为我的语法有误,因为我收到了这个错误:

There are errors in the configuration of this machine. Please fix
the following errors and try again:

shell provisioner:
* Shell provisioner `args` must be a string or array.

我尝试删除除第一个变量之外的所有变量,但之后根本没有设置。

2 个答案:

答案 0 :(得分:1)

我认为您的错误来自使用单词true。 在yaml中,布尔值应该是他们的字符串版本,“true”和“false”。

答案 1 :(得分:0)

作为最佳实践,您最好将环境变量放在项目上,因为将来可能会有更多项目使用不同的数据库。

对于每个项目,您都可以设置变量。

来源:http://laravel.com/docs/4.2/configuration#protecting-sensitive-configuration