okdewit / optimizely-php-sdk
Optimizely SDK for Full Stack PHP projects.
Requires
- php: >=5.5
- guzzlehttp/guzzle: ~6.2|~7.0
- justinrainbow/json-schema: ^1.6 || ^2.0 || ^4.0 || ^5.0
- lastguest/murmurhash: 1.3.0
- monolog/monolog: ^1.21|^2.0.0
Requires (Dev)
- icecave/parity: ^1.0 || ^2.0
- php-coveralls/php-coveralls: v2.3.0
- phpunit/phpunit: ^4.8|^5.0
- squizlabs/php_codesniffer: 3.*
- dev-master
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.x-dev
- 3.4.x-dev
- 3.4.0
- 3.3.x-dev
- 3.3.1
- 3.3.0
- 3.2.x-dev
- 3.2.0
- 3.1.x-dev
- 3.1.0
- 3.0.1
- 3.0.0
- 2.2.x-dev
- 2.2.1
- 2.2.0
- 2.1.x-dev
- 2.1.0
- 2.0.x-dev
- 2.0.1
- 2.0.0
- 2.0.0-beta1
- 1.5.x-dev
- 1.5.0
- 1.4.0
- 1.3.x-dev
- 1.3.0
- 1.2.x-dev
- 1.2.0
- 1.1.x-dev
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
- 0.1.0
- dev-patch-1
- dev-yasir/sem-ver
- dev-pr/211
- dev-oakbani/test-php-5.3
- dev-oakbani/toString-methods
- dev-oakbani/make-logging-psr3-compliant
- dev-oakbani/generate-md-docs
This package is auto-updated.
Last update: 2024-10-29 06:18:41 UTC
README
This is a forked repository, published separately from the mainstream Optimizely SDK on packagist. It is tagged as a new Major Release v4.0.0, and depends on Monolog v2.0.0 to resolve a conflict with Laravel 7 and 8 which can not use Monolog v1.0.0.
Optimizely PHP SDK
This repository houses the PHP SDK for use with Optimizely Full Stack and Optimizely Rollouts.
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.
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.
Getting Started
Installing the SDK
The Optimizely PHP SDK can be installed through Composer. Please use the following command:
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.
Using the SDK
Initialization
Create the Optimizely client, for example:
$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 for further detail.
$optimizelyClient = OptimizelyFactory::createDefaultInstance("your-sdk-key", <<DATAFILE>>, <<DATAFILE_AUTH_TOKEN>>);
To access your HTTPProjectConfigManager:
$configManager = $optimizelyClient->configManager;
Or you can also provide an implementation of the ProjectConfigManagerInterface
in the constructor:
$configManager = new HTTPProjectConfigManager(<<SDK_KEY>>); $optimizely = new Optimizely(<<DATAFILE>>, null, null, null, false, null, $configManager);
ProjectConfigManagerInterface
ProjectConfigManagerInterface
exposes getConfig
method for retrieving ProjectConfig
instance.
HTTPProjectConfigManager
HTTPProjectConfigManager
is an implementation of ProjectConfigManagerInterface
interface.
The fetch
method makes a blocking HTTP GET request to the configured URL to download the
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
$configManager = new HTTPProjectConfigManager(<<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 to learn how to set up your first Full Stack project and use the SDK.
Development
Unit tests
Running all tests
You can run all unit tests with:
./vendor/bin/phpunit
Contributing
Please see CONTRIBUTING.