Config cache in laravel 5 results in view not foun

2020-06-01 02:08发布

问题:

I'm tying to render a simple view:

public function test()
{
    return \View::make('test');
}

I cache my config :

$ php artisan config:cache
Configuration cache cleared!
Configuration cached successfully!

When I run it in a web browser I've got :

InvalidArgumentException in FileViewFinder.php line 140:
View [test] not found.
in FileViewFinder.php line 140
at FileViewFinder->findInPaths('test', array('/XXXXXX/resources/views')) in FileViewFinder.php line 77
at FileViewFinder->find('test') in Factory.php line 145
at Factory->make('test') in Facade.php line 213
... (framework backtrace)

I clear config cache...

$ php artisan config:clear
Configuration cache cleared!

...View is rendered (it's a simple HTML view resources/views/test.blade.php)

Why does it only work without cache config ?

回答1:

It does not work when your machine is running on vagrant (or another virtual environnement) and you run php artisan config:cache out of vagrant. Do you need to run this command in vagrant. The problem is about path routes (path are not the same in vagrant and out of vagrant).