Home  >  Article  >  Backend Development  >  在使用Lumen框架遇到的视图问题

在使用Lumen框架遇到的视图问题

WBOY
WBOYOriginal
2016-06-06 20:32:331603browse

最近下载了Lumen的懒人包 然后用了一下 在controller中使用

<code>return view('user');
</code>

就显示
在使用Lumen框架遇到的视图问题

但是在controller中使用

<code>return view()->file('..\resources\views\user.blade.php');
</code>

项目就显示正常了

resources\views 中是存在user.balde.php 的

不知有没有人最近在看Lumen,想请教一下为什么我指定了路径这个View才能使用

回复内容:

最近下载了Lumen的懒人包 然后用了一下 在controller中使用

<code>return view('user');
</code>

就显示
在使用Lumen框架遇到的视图问题

但是在controller中使用

<code>return view()->file('..\resources\views\user.blade.php');
</code>

项目就显示正常了

resources\views 中是存在user.balde.php 的

不知有没有人最近在看Lumen,想请教一下为什么我指定了路径这个View才能使用

感觉楼主应该是从 laravel4[一下简称 L4] 转过来的。
在 L4 上的写法是 View::make('user')
在 lumen 上 view() 是个 帮助函数,
如果 没有参数的话 返回 View 类的新建实例。
所以可以写成 return view()->make('user')
然后翻官方手册的话,return view('user')
这个写法也是支持的,所以应该是个 BUG,
安装下最新版吧~ composer update

首选声明,我没有实际用过这个lumen哈

我很好奇你在哪里看到这个形如“user.blade.php”的文件名可以直接view("user")而不是view("user.blade")

你可以试着echo下view()->exists('user.blade')看看是否能找到

lumen 中貌似不提供命名空间

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn