Search code examples
phplaravelvagrantlaravel-5homestead

Laravel 5 view not found when using vagrant and homestead


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

at FileViewFinder->findInPaths('welcome', array('/Users/mknb/work/API/testproject/resources/views'))

But shouldn't it say /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

InvalidArgumentException in FileViewFinder.php line 137: View [welcome] not found.

When using the exact same project without Homestead/Vagrant but with Virtual Hosts instead, I'm having no problems. So what could cause this?

This is my 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

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

Line 2 of the stacktrace looks like this

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?


Solution

  • 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