欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

laravel 实现页面静态化

laravel 实现页面静态化

2018年12月24日 15:45:11 煤堆里的黑猫、 阅读数:183                
    $path = public_path() . '/view/index.html';

    if (file_exists($path) && time() - filemtime($path) > 60) {
    //页面静态化
        ob_start();

        $htmlStrings = view('home.index')
            ->with('links', $links)
            ->with('config', $config)
            ->with('category', $cagegory)
            ->__toString();

        echo $htmlStrings;

        file_put_contents('view/index.html', ob_get_clean());
    }

	//输出静态文件
    \View::addExtension('html', 'php');//扩展名
    echo view()->file(public_path() . '/view/index.html');

                
           
来自  https://blog.csdn.net/weixin_42471570/article/details/85234415                            


普通分类: