Skip to content

Slim Framework HTTP cache middleware and service provider

License

Notifications You must be signed in to change notification settings

JimTools/Slim-HttpCache

This branch is 6 commits behind slimphp/Slim-HttpCache:1.x.

Folders and files

NameName
Last commit message
Last commit date
Apr 28, 2021
Dec 8, 2020
Dec 8, 2020
Jun 20, 2020
Jun 20, 2020
Jun 12, 2020
Dec 8, 2020
Mar 29, 2015
Mar 29, 2015
Jun 19, 2020
Jan 14, 2022
Jun 12, 2020
Jun 12, 2020
Dec 8, 2020

Repository files navigation

Slim Framework HTTP Cache

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 [email protected] instead of using the issue tracker.

Credits

License

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

About

Slim Framework HTTP cache middleware and service provider

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%