https://learnku.com/articles/...php
php7.4
nginx1.17
mysql5.7
windows10html
public function test(Request $request) { $view = view('test')->render(); Storage::disk('local')->put('views/' . $request->path(), $view); return $view; }
location / { root D:/wwwroot/demo/storage/app/views; index index.html; try_files $uri $uri.html @default; } location @default { root D:/wwwroot/demo/public; index index.php; try_files $uri $uri/ /index.php$is_args$query_string; }
这样就能在第一次访问时生成相应的静态网页,以后再访问时就会直接返回静态网页。mysql
实现过时删除、自动更新功能,大概就是获取views文件夹下的全部文件名,记录在案,而后按期清除,还能够主动发出请求触发更新。另外一个就是无损实现全站静态化,这须要覆盖 Foundations/helpers.php
中的 view()
方法,然而这个文件已经被建立自动加载映射了,正常状况下没法覆盖,你能够安装 funkjedi/composer-include-files
,它能够优先自动加载你自定义的php文件,这样就ok了。nginx
一般须要显示当前登陆用户的头像,静态化后就不能显示了?固然能够。sql
好比,认证后保存用户数据到浏览器,经过js把当前状态更新到静态的html上。windows
Laravel通用插件系统,使你的Laravel项目具有热插拔插件功能!浏览器