我在返回 Controller 特定功能的 View 时遇到了一些问题。
我的所有 View 都在我的应用程序的任何地方正常返回,即使在这个 Controller 中也是如此。当我尝试返回任何 View 时,包括我可以在其他地方返回的测试 View ,我总是以空白页结束。我的日志(PHP 和 Apache)是空的。
Controller
function firstfct($path){
$obj = new Foo\Bar($this);
$obj->Insert($path);
}
function ReturnsBlank(){
//Fetching some variables that I was able to dump
return \View::make('test'); //Blank
//return var_dump('FooBar'); // Returns "FooBar"
}
Foo/bar 文件
class SomeClass{
protected $listener;
public function __construct($listener)
{
$this->listener = $listener;
}
function Insert($path){
//Some stuff that it is working well
return $this->listener->ReturnsBlank();
}
}
test.blade.php
<pre>
Done!
</pre>
<hr/>
最佳答案
问题是您的 firstfct Controller 实际上并没有“返回”任何东西给 Laravel。该 View “返回”给函数 firstfct - 但您需要将其传递给函数
改变
function firstfct($path){
$obj = new Foo\Bar($this);
$obj->Insert($path);
}
到
function firstfct($path){
$obj = new Foo\Bar($this);
return $obj->Insert($path);
}
关于php - Laravel View Make 返回空白页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23636483/