Giter Club home page Giter Club logo

php-sdk's Introduction

Optimizely PHP SDK

Build Status Coverage Status Total Downloads Apache 2.0

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.

php-sdk's People

Contributors

alda-optimizely avatar aliabbasrizvi avatar caitlinrubin-optimizely avatar christaggart avatar cleentfaar avatar dcloues avatar elliotykim avatar fayyazarshad avatar jaeopt avatar juancarlostong avatar mauerbac avatar mfahadahmed avatar mikeproeng37 avatar mnoman09 avatar msohailhussain avatar nchilada avatar oakbani avatar onufryk avatar ozayr-zaviar avatar rashidsp avatar spea avatar wangjoshuah avatar yasirfolio3 avatar yuanc avatar zashraf1985 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.