欢迎各位兄弟 发布技术文章
这里的技术是共享的
来自 http://www.banbans.com/post/4
废话不多说,直接上代码
$view = view('welcome')->with('data','xxx');
$html = response($view)->getContent();
if (file_exists(storage_path() .'/demo/1.html')) {
return response()->file(storage_path() ."/demo/1.html");
}
if (! file_exists(storage_path() .'/demo')) {
mkdir(storage_path() .'/demo');
}
file_put_contents(storage_path() ."/demo/".'1.html',$html);
chmod(storage_path() ."/demo/'1.html", '0777');
return response()->file(storage_path() ."/demo/1.html");