Download the PHP package j-webb/laravel-unleash without Composer
On this page you can find all versions of the php package j-webb/laravel-unleash. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-unleash
Laravel Unleash
A simple Unleash component for Laravel. It is compatible with the Unlesah-hosted.com SaaS offering, Unleash Open-Source, and GitLab's Feature Flag system, which is built on Unleash.
V2 of this package is a wrapper and extension of the Unleash PHP SDK that is compatible with Laravel.
Getting started
1. Install the Laravel Unleash via Composer
2. Configure
Create local configuration (optional)
Required .env values
Optional .env values
Setting up the Middleware
The module comes bundled with middleware for you to perform a feature check on routes and/or controllers.
Once added to your Kernel.php
file, you can use this in any area where middleware is applicable.
As an example, you could use this in a controller.
See the Laravel Docs for more information.
Setting up a custom cache handler
If the cache option is enabled, by default the component will use the Laravel Cache module. By utilizing the UnleashCacheHandlerInterface
, you can create your own PSR-16 compatible implementation and override the unleash.cache.handler
config value with your handler class.
Setting up custom strategies
To add your own strategy, you can override or create your own Strategies Provider. A UnleashStrategiesProviderInterface
is included for convenience. Once your custom class is build, you should modify the unleash.strategy_provider
config value.
Overwriting default context provider
If you want to send more context by default, you can overwrite the UnleashContextProvider
. Make sure that your class implements the Unleash\Client\ContextProvider\UnleashContextProvider
interface (to prevent confusion with the UnleashContextProvider in this package, an option would be to alias it). After that, change the config value of unleash.context_provider
to your custom created class.
Usage
Checking individual features
Using array of features.
Note: The result matches that which would be returned from the official Unleash Proxy instances. This means you could use your Laravel application as an Unleash Proxy endpoint, which is compatible with the official client-side Unleash Proxy SDKs
Using middleware on a controller
Using middleware on a route
Because the component is a wrapper of the official Unleash Client SDK, you can pass relevant context to your checks:
Note: User ID information is automatically added to the context using the Laravel Auth module
Or get variant information
Blade
You can use the Unleash Blade directive for checking if a feature is enabled in your Blade templates:
Or if a feature is disabled:
All versions of laravel-unleash with dependencies
illuminate/support Version ^6|^7|^8|^9|^10.0|^11.0
illuminate/http Version ^6|^7|^8|^9|^10.0|^11.0
unleash/client Version ^1
symfony/cache Version ^5.3|^6.1
psr/cache Version ^1.0|^2.0|^3.0
psr/simple-cache Version ^1.0|^2.0|^3.0