knplabs / php-valid
This package is abandoned and no longer maintained.
No replacement package was suggested.
A HTTP cache validation toolkit
dev-master / 0.x-dev
2013-10-15 16:08 UTC
Requires
Requires (Dev)
- behat/behat: ~3@dev
- doctrine/orm: ~2.4
- phpspec/phpspec: ~2@dev
- symfony/framework-bundle: ~2
- symfony/http-kernel: ~2
Suggests
- doctrine/common: to use Doctrine listener rule
- symfony/http-kernel: to use kernel events and stackphp
This package is auto-updated.
Last update: 2022-09-23 13:38:22 UTC
README
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