拉威尔的速度实际上是that慢.500-not0毫秒是荒谬的;在调试模式下,我把时间降到了20毫秒.
The problem was Vagrant/VirtualBox + shared folders. I didn't realize they incurred such a performance hit. I guess because Laravel has so many dependencies (loads ~280 files) and each of those file reads is slow, it adds up really quick.
kreeves pointed me in the right direction, this blog post describes a new feature in Vagrant 1.5 that lets you rsync your files into the VM rather than using a shared folder.
Windows上没有本机rsync客户端,因此您必须使用cygwin.安装它,并确保选中net/rsync.将C:\cygwin64\bin
添加到您的路径中.[或者您可以将其安装在Win10/Bash上]
我用的是Puphet所以我的流浪者档案看起来有点搞笑.我不得不把它改成这样:
data['vm']['synced_folder'].each do |i, folder|
if folder['source'] != '' && folder['target'] != '' && folder['id'] != ''
config.vm.synced_folder "#{folder['source']}", "#{folder['target']}",
id: "#{folder['id']}",
type: "rsync",
rsync__auto: "true",
rsync__exclude: ".hg/"
end
end
Once you're all set up, try vagrant up
. If everything goes smoothly your machine should boot up and it should copy all the files over. You'll need to run vagrant rsync-auto
in a terminal to keep the files up to date. You'll pay a little bit in latency, but for 30x faster page loads, it's worth it!
如果你使用的是PhpStorm,它的自动上传功能甚至比rsync更好.PhpStorm创建了很多临时文件,这可能会让文件观察者感到困惑,但是如果你让它自己处理上传,它会很好地工作.
One more option is to use lsyncd. I've had great success using this on Ubuntu host -> FreeBSD guest. I haven't tried it on a Windows host yet.