mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
docs: Update php documentation to include context provider (#1000)
* Update php documentation to include context provider * Update leftover from java * Remove another Java leftover Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
This commit is contained in:
parent
f0490c4e43
commit
20929a0361
@ -76,4 +76,26 @@ $context = new UnleashContext(
|
||||
$unleash->isEnabled("someToggle", $context);
|
||||
```
|
||||
|
||||
|
||||
**b) Via a UnleashContextProvider**
|
||||
|
||||
This is a bit more advanced approach, where you configure a unleash-context provider. By doing this you do not have to rebuild or to pass the unleash-context object to every place you are calling `$unleash->isEnabled()`.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Unleash\Client\UnleashBuilder;
|
||||
|
||||
$contextProvider = new MyAwesomeContextProvider();
|
||||
$unleash = UnleashBuilder::create()
|
||||
->withAppName('my.php-app')
|
||||
->withInstanceId('your-instance-1')
|
||||
->withAppUrl('http://unleash.herokuapp.com/api/')
|
||||
->withContextProvider($contextProvider)
|
||||
->build();
|
||||
|
||||
// Anywhere in the code unleash will get the unleash context from your registered provider.
|
||||
$unleash->isEnabled("someToggle");
|
||||
```
|
||||
|
||||
> You can read more complete documentation in the [Client SDK repository](https://github.com/Unleash/unleash-client-php).
|
||||
|
Loading…
Reference in New Issue
Block a user