Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: optimizely/php-sdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: optimizely/php-sdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3.9.3
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 3 commits
  • 7 files changed
  • 2 contributors

Commits on Mar 13, 2023

  1. [FSSDK-8963] doc: Full Stack to Feature Experimentation Rename (#261)

    * [FSSDK-8963] Update README.md
    
    * [FSSDK-8963] Update composer description
    
    * [FSSDK-8963] Update function docs
    
    * Update composer.json
    
    Co-authored-by: Russell Loube <118555704+russell-loube-optimizely@users.noreply.github.com>
    
    * [FSSDK-8963] Move build badge to GitHub Actions result
    
    ---------
    
    Co-authored-by: Russell Loube <118555704+russell-loube-optimizely@users.noreply.github.com>
    (cherry picked from commit e3e76b7)
    Copy the full SHA
    dbc5153 View commit details
  2. [FSSDK-8963] Version bump (#262)

    (cherry picked from commit a32e27e)
    mikechu-optimizely committed Mar 13, 2023
    Copy the full SHA
    9c1e88a View commit details
  3. [FSSDK-8963] Update CHANGELOG.md (#263)

    * [FSSDK-8963] Update CHANGELOG.md
    
    * [FSSDK-8963] Fix CHANGELOG.md date
    
    (cherry picked from commit 34bebf0)
    mikechu-optimizely committed Mar 13, 2023
    Copy the full SHA
    b21964f View commit details
Showing with 66 additions and 28 deletions.
  1. +11 −0 CHANGELOG.md
  2. +50 −23 README.md
  3. +1 −1 composer.json
  4. +1 −1 src/Optimizely/Config/DatafileProjectConfig.php
  5. +1 −1 src/Optimizely/Event/Builder/EventBuilder.php
  6. +1 −1 src/Optimizely/Optimizely.php
  7. +1 −1 tests/EventTests/EventBuilderTest.php
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Optimizely PHP SDK Changelog

## 3.9.3
March 13, 2023

* We updated our README.md and other non-functional code to reflect that this SDK supports both Optimizely Feature Experimentation and Optimizely Full Stack. ([#261](https://github.com/optimizely/php-sdk/pull/261)).

## 3.9.2
October 5th, 2022

### Bug Fixes
* String type casting added to avoid deprecation notices when passing null to strlen. ([#253](https://github.com/optimizely/php-sdk/pull/253))

## 3.9.1
May 31st, 2022

73 changes: 50 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
# Optimizely PHP SDK
[![Build Status](https://travis-ci.org/optimizely/php-sdk.svg?branch=master)](https://travis-ci.org/optimizely/php-sdk)
[![Packagist](https://badgen.net/packagist/v/optimizely/optimizely-sdk)](https://packagist.org/packages/optimizely/optimizely-sdk)
[![Build Status](https://github.com/optimizely/php-sdk/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/optimizely/php-sdk/actions/workflows/php.yml?query=branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/optimizely/php-sdk/badge.svg?branch=master)](https://coveralls.io/github/optimizely/php-sdk?branch=master)
[![Total Downloads](https://poser.pugx.org/optimizely/optimizely-sdk/downloads)](https://packagist.org/packages/optimizely/optimizely-sdk)
[![Apache 2.0](https://img.shields.io/github/license/nebula-plugins/gradle-extra-configurations-plugin.svg)](http://www.apache.org/licenses/LICENSE-2.0)

This repository houses the PHP SDK for use with Optimizely Full Stack and Optimizely Rollouts.
This repository houses the PHP SDK for use with Optimizely Feature Experimentation and Optimizely Full Stack (legacy).

Optimizely Full Stack is A/B testing and feature flag management for product development teams. Experiment in any application. Make every feature on your roadmap an opportunity to learn. Learn more at https://www.optimizely.com/platform/full-stack/, or see the [documentation](https://docs.developers.optimizely.com/full-stack/docs).
Optimizely Feature Experimentation is an A/B testing and feature management tool for product development teams that enables you to experiment at every step. Using Optimizely Feature Experimentation allows for every feature on your roadmap to be an opportunity to discover hidden insights. Learn more at [Optimizely.com](https://www.optimizely.com/products/experiment/feature-experimentation/), or see the [developer documentation](https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/welcome).

Optimizely Rollouts is free feature flags for development teams. Easily roll out and roll back features in any application without code deploys. Mitigate risk for every feature on your roadmap. Learn more at https://www.optimizely.com/rollouts/, or see the [documentation](https://docs.developers.optimizely.com/rollouts/docs).
Optimizely Rollouts is [free feature flags](https://www.optimizely.com/free-feature-flagging/) for development teams. You can easily roll out and roll back features in any application without code deploys, mitigating risk for every feature on your roadmap.

## Getting Started
## Get Started

### Installing the SDK
Refer to the [PHP SDK's developer documentation](https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/php-sdk) for detailed instructions on getting started with using the SDK.

### Requirements

To access the Feature Management configuration in the Optimizely dashboard, please contact your Optimizely account executive.

### Install the SDK

The Optimizely PHP SDK can be installed through [Composer](https://getcomposer.org/). Please use the following command:

```
```bash
php composer.phar require optimizely/optimizely-sdk
```

### Feature Management Access
To access the Feature Management configuration in the Optimizely dashboard, please contact your Optimizely account executive.
## Use the PHP SDK

### Using the SDK
### Initialization

#### Initialization
Create the Optimizely client, for example:

```php
$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](#http_config_manager) for further detail.
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
$optimizelyClient = OptimizelyFactory::createDefaultInstance("your-sdk-key", <<DATAFILE>>, <<DATAFILE_AUTH_TOKEN>>);
@@ -50,10 +55,10 @@ $configManager = new HTTPProjectConfigManager(<<SDK_KEY>>);
$optimizely = new Optimizely(<<DATAFILE>>, null, null, null, false, null, $configManager);
```

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

#### <a name="http_config_manager"></a> 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.
@@ -63,31 +68,53 @@ project datafile and initialize an instance of the ProjectConfig.

Calling `fetch` will update the internal ProjectConfig instance that will be returned by `getConfig`.

##### Use HTTPProjectConfigManager
### Use HTTPProjectConfigManager

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

##### SDK key
### SDK key
Optimizely project SDK key; required unless source URL is overridden.

A notification will be triggered whenever a _new_ datafile is fetched and ProjectConfig is updated. To subscribe to these notifications, use the `$notificationCenter->addNotificationListener(NotificationType::OPTIMIZELY_CONFIG_UPDATE, $updateCallback)`.

#### Documentation
See the Optimizely Full Stack [developer documentation](https://developers.optimizely.com/x/solutions/sdks/reference/?language=php) to learn how to set up your first Full Stack project and use the SDK.
## SDK Development

## Development
### Unit Tests

### Unit tests

##### Running all tests
You can run all unit tests with:

```
```bash
./vendor/bin/phpunit
```

### Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md).

### Other Optimizely SDKs

- Agent - https://github.com/optimizely/agent

- Android - https://github.com/optimizely/android-sdk

- C# - https://github.com/optimizely/csharp-sdk

- Flutter - https://github.com/optimizely/optimizely-flutter-sdk

- Go - https://github.com/optimizely/go-sdk

- Java - https://github.com/optimizely/java-sdk

- JavaScript - https://github.com/optimizely/javascript-sdk

- PHP - https://github.com/optimizely/php-sdk

- Python - https://github.com/optimizely/python-sdk

- React - https://github.com/optimizely/react-sdk

- Ruby - https://github.com/optimizely/ruby-sdk

- Swift - https://github.com/optimizely/swift-sdk
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "optimizely/optimizely-sdk",
"description": "Optimizely SDK for Full Stack PHP projects.",
"description": "Optimizely PHP SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts",
"keywords": ["optimizely", "sdk"],
"license": "Apache-2.0",
"authors": [
2 changes: 1 addition & 1 deletion src/Optimizely/Config/DatafileProjectConfig.php
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ class DatafileProjectConfig implements ProjectConfigInterface
private $_accountId;

/**
* @var string Project ID of the Full Stack project.
* @var string Project ID of the Feature Experimentation project.
*/
private $_projectId;

2 changes: 1 addition & 1 deletion src/Optimizely/Event/Builder/EventBuilder.php
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ class EventBuilder
/**
* @const string Version of the Optimizely PHP SDK.
*/
const SDK_VERSION = '3.9.1';
const SDK_VERSION = '3.9.3';

/**
* @var string URL to send event to.
2 changes: 1 addition & 1 deletion src/Optimizely/Optimizely.php
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ class Optimizely
public $notificationCenter;

/**
* Optimizely constructor for managing Full Stack PHP projects.
* Optimizely constructor for managing Feature Experimentation PHP projects.
*
* @param $datafile string JSON string representing the project.
* @param $eventDispatcher EventDispatcherInterface
2 changes: 1 addition & 1 deletion tests/EventTests/EventBuilderTest.php
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ public function setUp()
]],
'revision' => '15',
'client_name' => 'php-sdk',
'client_version' => '3.9.1',
'client_version' => '3.9.3',
'anonymize_ip'=> false,
'enrich_decisions' => true,
];