slim/http-cache 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

slim/http-cache

最新稳定版本:1.3.0

Composer 安装命令:

composer require slim/http-cache

包简介

Slim Framework HTTP cache middleware and service provider

README 文档

README

Build Status Coverage Status Latest Stable Version License

This repository contains a Slim Framework HTTP cache middleware and service provider.

Install

Via Composer

$ composer require slim/http-cache

Requires Slim 4.0.0 or newer.

Usage

declare(strict_types=1);

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

require __DIR__.'/../vendor/autoload.php';

$app = \Slim\Factory\AppFactory::create();

// Register the http cache middleware.
$app->add(new \Slim\HttpCache\Cache('public', 86400));

// Create the cache provider.
$cacheProvider = new \Slim\HttpCache\CacheProvider();

// Register a route and let the closure callback inherit the cache provider.
$app->get(
    '/',
    function (Request $request, Response $response, array $args) use ($cacheProvider): Response {
        // Use the cache provider.
        $response = $cacheProvider->withEtag($response, 'abc');

        $response->getBody()->write('Hello world!');

        return $response;
    }
);

$app->run();

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email security@slimframework.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 2.67M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 124
  • 点击次数: 1
  • 依赖项目数: 33
  • 推荐数: 2

GitHub 信息

  • Stars: 116
  • Watchers: 12
  • Forks: 24
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04