{"id":19935050,"url":"https://github.com/optimizely/php-sdk","last_synced_at":"2025-04-13T05:07:43.360Z","repository":{"id":13501242,"uuid":"74388261","full_name":"optimizely/php-sdk","owner":"optimizely","description":"PHP SDK for Optimizely Feature Experimentation and Optimizely Full Stack (legacy).　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　🚨 Calling All Developers! 🚨　　　　　　　　　　　　　We invite you to provide your input on Feature Experimentation by completing this brief survey: https://qualtricsxm8wgr4vwty.qualtrics.com/jfe/form/SV_8AI3F5BovuSiulo","archived":false,"fork":false,"pushed_at":"2025-03-17T11:12:55.000Z","size":1783,"stargazers_count":19,"open_issues_count":3,"forks_count":30,"subscribers_count":103,"default_branch":"master","last_synced_at":"2025-04-13T05:07:37.830Z","etag":null,"topics":["optimizely-environment-prod","optimizely-environment-public","optimizely-owner-px"],"latest_commit_sha":null,"homepage":"https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/php-sdk","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/optimizely.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-21T17:30:53.000Z","updated_at":"2025-03-16T12:37:14.000Z","dependencies_parsed_at":"2024-06-20T00:10:25.411Z","dependency_job_id":"7f0f915f-499e-4cfb-9460-d36f332403df","html_url":"https://github.com/optimizely/php-sdk","commit_stats":{"total_commits":213,"total_committers":31,"mean_commits":6.870967741935484,"dds":0.7887323943661972,"last_synced_commit":"34bebf03a9748a37bfbae5fa08f4e1bb17aba4fd"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fphp-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fphp-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fphp-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Fphp-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/optimizely","download_url":"https://codeload.github.com/optimizely/php-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665747,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["optimizely-environment-prod","optimizely-environment-public","optimizely-owner-px"],"created_at":"2024-11-12T23:18:38.691Z","updated_at":"2025-04-13T05:07:43.340Z","avatar_url":"https://github.com/optimizely.png","language":"PHP","readme":"# Optimizely PHP SDK\n[![Packagist](https://badgen.net/packagist/v/optimizely/optimizely-sdk)](https://packagist.org/packages/optimizely/optimizely-sdk)\n[![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)\n[![Coverage Status](https://coveralls.io/repos/github/optimizely/php-sdk/badge.svg?branch=master)](https://coveralls.io/github/optimizely/php-sdk?branch=master)\n[![Total Downloads](https://poser.pugx.org/optimizely/optimizely-sdk/downloads)](https://packagist.org/packages/optimizely/optimizely-sdk)\n[![Apache 2.0](https://img.shields.io/github/license/nebula-plugins/gradle-extra-configurations-plugin.svg)](http://www.apache.org/licenses/LICENSE-2.0)\n\nThis repository houses the PHP SDK for use with Optimizely Feature Experimentation and Optimizely Full Stack (legacy).\n\nOptimizely 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).\n\nOptimizely 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.\n\n## Get Started\n\nRefer 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.\n\n### Requirements\n\nTo access the Feature Management configuration in the Optimizely dashboard, please contact your Optimizely account executive.\n\nSDK version 4.0.0 requires PHP8+.\nSDK version 3 requires PHP5.5+ up to PHP7.\n\n### Install the SDK\n\nThe Optimizely PHP SDK can be installed through [Composer](https://getcomposer.org/). Please use the following command:\n\n```bash\nphp composer.phar require optimizely/optimizely-sdk\n```\n\n## Use the PHP SDK\n\n### Initialization\n\nCreate the Optimizely client, for example:\n\n```php\n\u003c?php\n\nuse Optimizely\\Optimizely;\n\n$optimizely = new Optimizely(\u003c\u003cDATAFILE\u003e\u003e);\n```\n\nOr 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.\n\n```php\n\u003c?php\n\nuse Optimizely\\OptimizelyFactory;\n\n$optimizelyClient = OptimizelyFactory::createDefaultInstance(\n    \"your-sdk-key\",\n    \u003c\u003cDATAFILE\u003e\u003e,\n    \u003c\u003cDATAFILE_AUTH_TOKEN\u003e\u003e\n);\n```\nTo access your HTTPProjectConfigManager:\n\n```php\n\u003c?php\n\nuse Optimizely\\Optimizely;\n\n/** @var Optimizely $optimizelyClient */\n$configManager = $optimizelyClient-\u003econfigManager;\n```\n\nOr 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:\n\n```php\n\u003c?php\n\nuse Optimizely\\Optimizely;\nuse Optimizely\\ProjectConfigManager\\HTTPProjectConfigManager;\n\n$configManager = new HTTPProjectConfigManager(\u003c\u003cSDK_KEY\u003e\u003e);\n$optimizely = new Optimizely(\n    \u003c\u003cDATAFILE\u003e\u003e,\n    null,\n    null,\n    null,\n    false,\n    null,\n    $configManager\n);\n```\n\n### ProjectConfigManagerInterface\n[`ProjectConfigManagerInterface`](https://github.com/optimizely/php-sdk/blob/master/src/Optimizely/ProjectConfigManager/ProjectConfigManagerInterface.php) exposes `getConfig` method for retrieving `ProjectConfig` instance.\n\n### \u003ca name=\"http_config_manager\"\u003e\u003c/a\u003e HTTPProjectConfigManager\n\n[`HTTPProjectConfigManager`](https://github.com/optimizely/php-sdk/blob/master/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php)\nis an implementation of `ProjectConfigManagerInterface` interface.\n\nThe `fetch` method makes a blocking HTTP GET request to the configured URL to download the\nproject datafile and initialize an instance of the ProjectConfig.\n\nCalling `fetch` will update the internal ProjectConfig instance that will be returned by `getConfig`.\n\n### Use HTTPProjectConfigManager\n\n```php\n\u003c?php\n\nuse Optimizely\\ProjectConfigManager\\HTTPProjectConfigManager;\n\n$configManager = new HTTPProjectConfigManager(\u003c\u003cSDK_KEY\u003e\u003e);\n```\n\n### SDK key\nOptimizely project SDK key; required unless source URL is overridden.\n\nA notification will be triggered whenever a _new_ datafile is fetched and ProjectConfig is updated. To subscribe to these notifications, use the `$notificationCenter-\u003eaddNotificationListener(NotificationType::OPTIMIZELY_CONFIG_UPDATE, $updateCallback)`.\n\n## SDK Development\n\n### Unit Tests\n\nYou can run all unit tests with:\n\n```bash\n./vendor/bin/phpunit\n```\n\n### Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md).\n\n### Other Optimizely SDKs\n\n- Agent - https://github.com/optimizely/agent\n\n- Android - https://github.com/optimizely/android-sdk\n\n- C# - https://github.com/optimizely/csharp-sdk\n\n- Flutter - https://github.com/optimizely/optimizely-flutter-sdk\n\n- Go - https://github.com/optimizely/go-sdk\n\n- Java - https://github.com/optimizely/java-sdk\n\n- JavaScript - https://github.com/optimizely/javascript-sdk\n\n- PHP - https://github.com/optimizely/php-sdk\n\n- Python - https://github.com/optimizely/python-sdk\n\n- React - https://github.com/optimizely/react-sdk\n\n- Ruby - https://github.com/optimizely/ruby-sdk\n\n- Swift - https://github.com/optimizely/swift-sdk\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimizely%2Fphp-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foptimizely%2Fphp-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimizely%2Fphp-sdk/lists"}