Skip to content

Commit

Permalink
docs: Add steps for sdk key init (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
oakbani authored and jaeopt committed May 28, 2020
1 parent 6baaf03 commit b0c4ef7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,32 @@ To access the Feature Management configuration in the Optimizely dashboard, plea
#### Initialization
Create the Optimizely client, for example:

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

You can also provide an implementation of the `ProjectConfigManagerInterface` in the constructor:
Or you may also use OptimizelyFactory method to create an optimizely client using your SDK key and an optional fallback datafile. Using this method internally creates an HTTPProjectConfigManager. See [HTTPProjectConfigManager](#http_config_manager) for further detail.

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

```php
$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
$configManager = new HTTPProjectConfigManager(<<SDK_KEY>>);
$optimizely = new Optimizely(<<DATAFILE>>, null, null, null, false, null, $configManager);
```

#### ProjectConfigManagerInterface
[`ProjectConfigManagerInterface`](https://github.com/optimizely/php-sdk/blob/master/src/Optimizely/ProjectConfigManager/ProjectConfigManagerInterface.php) exposes `getConfig` method for retrieving `ProjectConfig` instance.

#### HTTPProjectConfigManager
#### <a name="http_config_manager"></a> HTTPProjectConfigManager

[`HTTPProjectConfigManager`](https://github.com/optimizely/php-sdk/blob/master/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php)
is an implementation of `ProjectConfigManagerInterface` interface.
Expand All @@ -54,7 +65,7 @@ Calling `fetch` will update the internal ProjectConfig instance that will be ret

##### Use HTTPProjectConfigManager

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

Expand Down

0 comments on commit b0c4ef7

Please sign in to comment.