Skip to content

Commit

Permalink
Fix: Code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Aug 29, 2023
1 parent 3fd73a2 commit d7c677d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,41 @@ php composer.phar require optimizely/optimizely-sdk
Create the Optimizely client, for example:

```php
<?php

use Optimizely\Optimizely;

$optimizely = new Optimizely(<<DATAFILE>>);
```

Or you may also use OptimizelyFactory method to create an optimizely client using your SDK key, an optional fallback datafile and an optional datafile access token. Using this method internally creates an HTTPProjectConfigManager. See [HTTPProjectConfigManager](#use-httpprojectconfigmanager) for further detail.

```php
<?php

use Optimizely\OptimizelyFactory;

$optimizelyClient = OptimizelyFactory::createDefaultInstance("your-sdk-key", <<DATAFILE>>, <<DATAFILE_AUTH_TOKEN>>);
```
To access your HTTPProjectConfigManager:

```php
<?php

use Optimizely\Optimizely;

/** @var Optimizely $optimizelyClient */
$configManager = $optimizelyClient->configManager;
```

Or you can also provide an implementation of the [`ProjectConfigManagerInterface`](https://github.com/optimizely/php-sdk/blob/master/src/Optimizely/ProjectConfigManager/ProjectConfigManagerInterface.php) in the constructor:

```php
<?php

use Optimizely\Optimizely;
use Optimizely\ProjectConfigManager\HTTPProjectConfigManager;

$configManager = new HTTPProjectConfigManager(<<SDK_KEY>>);
$optimizely = new Optimizely(<<DATAFILE>>, null, null, null, false, null, $configManager);
```
Expand All @@ -74,6 +92,10 @@ Calling `fetch` will update the internal ProjectConfig instance that will be ret
### Use HTTPProjectConfigManager

```php
<?php

use Optimizely\ProjectConfigManager\HTTPProjectConfigManager;

$configManager = new HTTPProjectConfigManager(<<SDK_KEY>>);
```

Expand Down

0 comments on commit d7c677d

Please sign in to comment.