Get support for KnpLabs/valid-http-cache

If you're new to LTH, please see our FAQ for more information on what it is we do.

Support Options

Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:

View Open Issues

Take a look to see if anyone else has experienced the same issue as you and if they managed to solve it.

Open an Issue

Make sure to read any relevant guidelines for opening issues on this repo before posting a new issue.

Sponsor directly

Check out the page and see if there are any options to sponsor this project or it's developers directly.

KnpLabs/valid-http-cache

php-valid

What

A php 5.3+ library to help manage HTTP/1.1 cache validation headers, using the symfony/HttpFoundation layer.

Why

Because there is no known library that provides a clean, decoupled way to manage them. The actual docs just shows dirty controller examples.

How

By observing requests and asking Rule instances if response has changed since last time client asked, either using If-Modified-Since or ETag headers.

Install


composer require "knplabs/valid=~0.1@dev"

Use


<?php

class CustomRule implements Knp\Valid\Rule\LastModified, Knp\Valid\Rule\ETag
{
    public function supports(Request $request)
    {
        return true;
    }

    public function getETag(Request $request)
    {
        return 'something';
    }

    public function getLastModified(Request $request)
    {
        return new \DateTime;
    }
}

$kernel = new AppCache(
    new Knp\Valid\Kernel(
        new AppKernel('prod', false),
        new Knp\Valid\ResponseManipulator(array(
            new Knp\Valid\Doctrine\ListenerRule,
            new CustomRule,
        ))
    )
);

$kernel->handle(Request::createFromGlobals())->send();

Contribute


composer install --dev --prefer-dist

vim features/**/*.feature
behat
phpspec desc Knp\Valid\*
phpspec run

Our Mission

We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.

Interesting Articles

Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated

p-e622a1a2