使用 vagrant 和 homestead 时找不到 Laravel 5 视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31021269/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5 view not found when using vagrant and homestead
提问by Musterknabe
UPDATE START
更新开始
Instead of using return view('welcome');
I now used return 'woo. It works.'
which made it work. So it seems like the view pathes configured incorrectly. Does someone know if I could be right with my assumption? 'Cause the stacktrace of the error says something along the lines
而不是使用return view('welcome');
我现在使用return 'woo. It works.'
它使它工作。所以看起来视图路径配置不正确。有人知道我的假设是否正确吗?因为错误的堆栈跟踪说明了一些事情
at FileViewFinder->findInPaths('welcome', array('/Users/mknb/work/API/testproject/resources/views'))
在 FileViewFinder->findInPaths('welcome', array('/Users/mknb/work/API/testproject/resources/views'))
But shouldn't it say /home/vagrant/testproject/resources/views
?
但不应该说/home/vagrant/testproject/resources/views
吗?
UPDATE END
更新结束
I'm using Laravel since a few weeks or months now and now wanted to also use Laravel together with Homestead. The problem I'm having now, is, after editing my Homestead.yaml
,the /etc/hosts
and starting vagrant vagrant up
I'm getting the error
我已经使用 Laravel 几周或几个月了,现在还想将 Laravel 与 Homestead 一起使用。我现在遇到的问题是,在编辑我的Homestead.yaml
,/etc/hosts
并开始 vagrant 后,vagrant up
我收到了错误
InvalidArgumentException in FileViewFinder.php line 137: View [welcome] not found.
FileViewFinder.php 第 137 行中的 InvalidArgumentException:未找到视图 [welcome]。
When using the exact same project without Homestead/Vagrant but with Virtual Hosts instead, I'm having no problems. So what could cause this?
当使用完全相同的项目而不使用 Homestead/Vagrant 而使用虚拟主机时,我没有问题。那么是什么原因造成的呢?
This is my Homestead.yaml
这是我的 Homestead.yaml
ip: "192.168.10.10"
memory: 2048
cpus: 1
hostname: testproject
name: testproject
provider: virtualbox
authorize: /Users/mknb/.ssh/id_homestead.pub
keys:
- /Users/mknb/.ssh/id_homestead
folders:
- map: "/Users/mknb/work/API/testproject"
to: "/home/vagrant/testproject"
sites:
- map: testproject.app
to: "/home/vagrant/testproject/public"
databases:
- homestead
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
And this is the /etc/hosts
这是 /etc/hosts
192.168.10.10 testproject.app
192.168.10.10 testproject.app
Well, at least it seems to work, that the server has been started, etc. but why am I getting this error? I also tried to clear my config cache and route cache with the following two commands
好吧,至少它似乎可以工作,服务器已经启动等等,但是为什么我会收到这个错误?我还尝试使用以下两个命令清除我的配置缓存和路由缓存
php artisan config:cache
and php artisan:route:cache
php artisan config:cache
和 php artisan:route:cache
Line 2 of the stacktrace looks like this
堆栈跟踪的第 2 行看起来像这样
at FileViewFinder->findInPaths('welcome', array('/Users/mknb/work/API/testproject/resources/views')) in FileViewFinder.php line 79
But shouldn't my vagrant path be set here? Can this be the problem?
但是我的流浪路径不应该设置在这里吗?这可能是问题吗?
回答by Musterknabe
I finally fixed the issue.
我终于解决了这个问题。
I connected to my vagrant box with vagrant ssh
and afterwards navigated to my testproject cd testproject
and ran the command to regenerate the config with php artisan config:cache
我连接到我的流浪盒,vagrant ssh
然后导航到我的测试项目cd testproject
并运行命令以重新生成配置php artisan config:cache
回答by kdverma
check your folder name(pathname error)
检查您的文件夹名称(路径名错误)
example- return view('Country.add');
return view('country.add');
例子—— return view('Country.add');
return view('country.add');