Skip to content

Commit 5ab0d64

Browse files
authored
docs: Add steps for sdk key init (#193)
1 parent 0be9ae0 commit 5ab0d64

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Diff for: README.md

+15-4
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,32 @@ To access the Feature Management configuration in the Optimizely dashboard, plea
2828
#### Initialization
2929
Create the Optimizely client, for example:
3030

31-
```
31+
```php
3232
$optimizely = new Optimizely(<<DATAFILE>>);
3333
```
3434

35-
You can also provide an implementation of the `ProjectConfigManagerInterface` in the constructor:
35+
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.
36+
37+
```php
38+
$optimizelyClient = OptimizelyFactory::createDefaultInstance("your-sdk-key", <<DATAFILE>>);
39+
```
40+
To access your HTTPProjectConfigManager:
3641

42+
```php
43+
$configManager = $optimizelyClient->configManager;
3744
```
45+
46+
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:
47+
48+
```php
3849
$configManager = new HTTPProjectConfigManager(<<SDK_KEY>>);
3950
$optimizely = new Optimizely(<<DATAFILE>>, null, null, null, false, null, $configManager);
4051
```
4152

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

45-
#### HTTPProjectConfigManager
56+
#### <a name="http_config_manager"></a> HTTPProjectConfigManager
4657

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

5566
##### Use HTTPProjectConfigManager
5667

57-
```
68+
```php
5869
$configManager = new HTTPProjectConfigManager(<<SDK_KEY>>);
5970
```
6071

0 commit comments

Comments
 (0)