How to map project directory in Homestead.yaml usi

2019-05-31 21:59发布

问题:

I have a per-project installation of Homestead in my Laravel project, using the guide at https://laravel.com/docs/5.4/homestead#per-project-installation.

I want the Homestead.yaml file to map the project directory as a folder accessible in the Vagrant VM.

I want to do this such that the Homestead.yaml file can be shared between development machines without alteration.

The Homestead.yaml file is in the project directory as is the Vagrantfile file.

Therefore I want to identify the project directory relatively, rather than by its full path.

Something like:

folders:
    -
        map: %CurrentDir%
        to: /home/vagrant/Code/project

(I invented %CurrentDir% for the sake of this example.)

Or even better without hardcoding the name of the project directory.

I'm on Windows and would prefer a platform-agnostic solution.

How can I do this?

回答1:

This works on macOSX w/ vagrant 2.0.1 / homestead 6.5:

folders:
    -
        map: ./
        to: /home/vagrant/code/project


回答2:

On Windows 10 this works:

folders:
    -
        map: %CurrentDir%
        to: /home/vagrant/Code/project

Yet to test on another platform...