0
votes

I'm developing various PHP packages in a global / shared folder, and symlinking them to various development setups, which works fine with a basic localhost setup.

However, I'm running into issues when I try to achieve the same thing inside Vagrant, as it doesn't support symlinks in synced folders (or at least has security issues).

I was advised to use synced folders to get round this, but although Vagrant tells me it's mounting the folders, when I ssh in, they are empty.

To illustrate, this is my setup:

Global packages repository (all development environments link here):

+- shared_drive
    +- packages
        +- PackageFoo
        +- PackageBar
        +- PackageBaz

Localhost (which works):

+- work_drive
    +- project
        +- vendor
            +- davestewart
                +- PackageFoo     <= symlink to /shared_drive/packages/PackageFoo

VM (which doesn't work):

+- vagrant
    +- project                    <= mapped to /work_drive/project
        +- vendor
            +- davestewart
                +- PackageFoo     <= mapped to /shared_drive/packages/PackageFoo

The paths are correct, I can cd everywhere.

I've tried the various sync types (default, nfs, rsync).

So no matter what I do, an ls in Vagrant shows vendor/davestewart/ to be empty.

Is this even the right approach? All I want to be able to do is edit and test the original package files in all development environments I set up.

OSX / Yosemite VirtualBox 5.1

1

1 Answers

0
votes

In lieu of any answers, I've managed to solve the problem by turning it on its head.

Rather than trying to cajole Vagrant into following an external symlink (which the docs themselves say is inconsistent across platforms) I've:

  • Set the original external symlink /shared_drive/packages/... as a Vagrant synced folder
  • Internally symlinked the original source /project/vendor/... to this folder

More visually:

+- vagrant
    +- shared
    |   +- packages               <= synced (external) folder to /shared_drive/packages/
    |       +- PackageFoo
    |       +- PackageBar
    |       +- PackageBaz
    |
    +- project
        +- vendor
            +- davestewart
                +- PackageFoo     <= symlink (internal) to /shared/packages/PackageFoo/

Totally easy to set up, it's fast, PHP is happy, and it should work across all OSes :)