In DeSmart we use Vagrant on a daily basis. Whatever the reason to work on the system without native support for NFS (Network File System), yes, I'm talking about Windows, you can feel that every request to localhost can be a pain in the ass.
3.2s to load the home page with one db query? Seriously?!
Ok, so really what can we do about that? We are working on Windows and there is no native support for anything else than Synced folders.
Same situation happens when you’re trying to work on the files directly on a virtual machine doing stuff like:
git status //etc composer install
We face another problem when we use synced folders on the apache server, running from virtual machine, using synced files in vhost file. This is the reason why that request takes a long time to serve even cached files.
I just switched from Vim to another IDE, so I don’t have the need or possibility to work inside a machine any more. When I worked with Vim, I never synced my project files with host machine. That way it worked pretty smoothly, because I didn’t need to use sync folders. My whole dev env was inside the virtual machine and there was just one bash script to set that up, we all love Vim ;)
Back to the topic, I found promising repository, at least the most updated one, with some WinNFSd source code. Based on that, and including some minor pull requests, I was able to create a binary that works quite nicely.
Here is what you CANNOT do:
composerinstall in some cases, if your package needs to compile some binaries, basically that makes it impossible to execute a command
Here is what you CAN do:
- work with shared folders blazing fast
A known issue:
- you need to execute
nfsservicehalt before each
Feel free to dig into it, and follow instructions from WIKI page.
All of that will force you to have php and composer on your host machine, in this case Windows.
I didn’t find a way to make it possible to execute composer install when NFS is switched on in my puphet file.
Here is my flow when I need to execute composer install
- reload vagrant
- change back to NFS
- reload vagrant
This is not as bad as it sounds, it’s much better to reload your vagrant than wait 3s on every request to your localhost.
Plus have a look at this:
This is the same homepage in about 0.5s. Nice one!
You need to get used to executing vagrante reload when needed, but you can improve your daily workflow with that.