andreizakharkin/custom-static-caching

dev-master 2017-06-20 13:32 UTC

This package is not auto-updated.

Last update: 2024-09-29 04:49:20 UTC


README

自定义静态缓存

Laravel 兼容性

Laravel 5 已经发布啦!!

安装

Composer

通过 composer 下载。

composer require andreizakharkin/custom-static-caching:dev-master

Laravel

将服务提供者注册到您的应用程序中。

打开 config/app.php 并找到 providers 键。将 CustomStaticCacheServiceProvider 添加到数组中。

	...
	Zakharkin\CustomStaticCache\CustomStaticCacheServiceProvider::class,
	...

发布供应商配置

	php artisan vendor:publish --provider="Zakharkin\CustomStaticCache\CustomStaticCacheServiceProvider" --tag="config"

使用方法

有两个主要功能可以帮助您使用静态缓存。

checkAndShow() - 可以检查和渲染缓存文件的函数

save() - 保存缓存文件的函数

您可以在应用程序的任何地方使用这些函数。唯一的规则是需要遵循的是,在自动加载完成后必须触发 checkAndShow() 函数

在 public/index.php 中的示例用法

	...
	
	require __DIR__.'/../bootstrap/autoload.php';
	
	\Zakharkin\CustomStaticCache\CustomStaticCache::getInstance()->checkAndShow();
	
	...
	
	$kernel->terminate($request, $response);
	
	\Zakharkin\CustomStaticCache\CustomStaticCache::getInstance()->save();