Laravel Homestead同时使用Windows和Mac

时间:2015-06-24 15:47:38

标签: php git laravel vagrant homestead

根据Laravel的5.1文档关于在每个项目的基础上使用Homestead,我运行命令在我的项目的Git存储库中创建一个Homestead Vagrant文​​件,我在我的Macbook上做了这个。这是Homestead.yaml:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
hostname: projectname
name: projectname
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: "/Users/user/Sites/personal/projectname"
      to: "/home/vagrant/projectname"

sites:
    - map: homestead.app
      to: "/home/vagrant/projectname/public"

databases:
    - projectname

variables:
    - key: APP_ENV
      value: local

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 93000
#       to: 9300
#     - send: 7777
#       to: 777
#       protocol: udp

问题是,在将其推送到Git并关闭我的PC后,Homestead.yaml文件中的路径现在完全错误,因此无法正常工作......

如何将Homestead.yaml中的路径抽象为环境变量,以便我可以跨操作系统共享流浪的虚拟机?

1 个答案:

答案 0 :(得分:4)

Managed to solve it!

If I set the folder to "." it will use the current directory which works for both Mac and Windows!

...

folders:
    - map: "."
      to: "/home/vagrant/projectname"

...

Meaning now I have a Homestead vagrant machine in Git that I can use on both Mac and Windows :D