Download the PHP package henzeb/laravel-pennant-cache without Composer

On this page you can find all versions of the php package henzeb/laravel-pennant-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-pennant-cache

Cache driver for Laravel Pennant

Build Status Latest Version on Packagist Total Downloads License

This package adds a cache driver for Laravel Pennant that stores feature flag values using any Laravel cache store, e.g. redis, memcached, dynamodb or array.

Why

Pennant ships with array and database drivers out of the box, and both are good at what they're meant for: array is great for testing since it never persists beyond a single request, and database is a solid production option, storing every feature value in its own table. This driver is just another option for when you'd rather reuse a cache store you already have running — store can point at any store your config/cache.php defines, including its own database cache store, so this doesn't have to mean giving up a database backend either.

Installation

Add a cache entry to the stores section of config/pennant.php, pointing store at whichever cache store (as configured in config/cache.php) should hold the feature values:

Tip: consider pointing store at a cache store dedicated to Pennant rather than reusing your app's default one, so feature flags aren't flushed by a stray Cache::flush() or evicted to make room for unrelated cache entries. For example, define a separate redis store in config/cache.php using its own connection/database:

and point this driver at it: 'store' => 'pennant'.

Configuration

Key Default Description
store app's default cache store The name of the cache store (from config/cache.php) to read and write feature values from.
prefix pennant Prefix used for every cache key this driver writes, to avoid colliding with unrelated cache keys.
index {prefix}:index Cache key used to keep track of which feature/scope pairs have been stored, for stored() and purge(). Set this explicitly if you run more than one cache store against the same underlying cache store, so their indexes don't collide.
ttl null (forever) Seconds until a stored feature value expires. Left at null, values are stored with forever() and only disappear when deleted, purged, or evicted by the cache store itself (e.g. Redis under memory pressure).

Activating/deactivating without losing the payload

Usually, when you have a feature flag with a payload, deactivating it means losing that payload — activating it again means setting the payload again from scratch. This driver treats a plain true/false (what Feature::activate() and ::deactivate() pass along) purely as an on/off toggle, and keeps the previously stored payload untouched, so a feature can be switched off and back on without losing its data:

Passing an actual payload (anything other than a literal true/false) always overwrites the stored value, regardless of whether the feature was active or not. If a feature is activated for the very first time with no payload of its own, and it has a Feature::define() resolver whose default is itself a payload (not a plain boolean), that default is used instead of an empty value.

Note: Pennant's own Decorator keeps a local, per-request memoization of every value it reads or writes, and assumes the value it just wrote is exactly the value it will read back. Because this driver can return a different, previously stored payload than what was just passed to activate()/deactivate(), that assumption doesn't hold within the same request. In practice this rarely matters — Pennant flushes that local cache at the start of every request/queued job/Octane tick — but if you activate/deactivate and immediately read the value back within the same request (e.g. in a test), call Feature::flushCache() in between to see the driver's real state rather than the Decorator's stale local copy.

Testing this package

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.


All versions of laravel-pennant-cache with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/pennant Version ^1.18.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package henzeb/laravel-pennant-cache contains the following files

Loading the files please wait ...