Laravel 5 中的配置缓存导致未找到视图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28676605/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:00:19  来源:igfitidea点击:

Config cache in laravel 5 results in view not found

phplaravellaravel-5

提问by rap-2-h

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)

...呈现视图(这是一个简单的 HTML 视图resources/views/test.blade.php

Why does it only work without cache config ?

为什么它只能在没有缓存配置的情况下工作?

回答by rap-2-h

It does not work when your machine is running on vagrant (or another virtual environnement) and you run php artisan config:cacheout 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).

当您的机器在 vagrant(或其他虚拟环境)上运行并且您用完php artisan config:cache了 vagrant时,它不起作用。你需要在 vagrant.js 中运行这个命令吗?问题在于路径路由(流浪者和流浪者之外的路径不同)。