devcycle / php-server-sdk
DevCycle PHP Server SDK
Installs: 65 022
Dependents: 1
Suggesters: 0
Security: 0
Stars: 18
Watchers: 6
Forks: 2
Open Issues: 6
Requires
- php: >=8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^2.0
- open-feature/sdk: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^v3.49.0
- phpunit/phpunit: ^10.5.10
- dev-main
- 2.0.2
- 2.0.1
- 2.0.0
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-jamie/oidc
- dev-dependabot/composer/friendsofphp/php-cs-fixer-3.60.0
- dev-dependabot/composer/guzzlehttp/guzzle-7.9.2
- dev-JamieSinn-patch-1
- dev-dependabot/composer/guzzlehttp/psr7-2.7.0
- dev-dependabot/composer/phpunit/phpunit-10.5.26
- dev-dependabot/composer/open-feature/sdk-2.0.7
- dev-elliot-hi
- dev-use-tagged-release-action
- dev-fix-release-action
- dev-update-release-to-new-pattern
- dev-DVC-7931-automated-release-action
- dev-json-defaulting-handled
This package is auto-updated.
Last update: 2024-10-24 19:05:51 UTC
README
Welcome to the DevCycle PHP SDK, initially generated via the DevCycle Bucketing API.
Requirements
PHP 8.0 and later.
Installation
Composer Installation
To install the bindings via Composer, add the following to composer.json
:
{ "require": { "devcycle/php-server-sdk": "*" } }
Then run composer install
Getting Started
Please follow the installation procedure and then run the following:
<?php require_once(__DIR__ . '/vendor/autoload.php'); use DevCycle\Api\DevCycleClient; use DevCycle\Model\DevCycleOptions; use DevCycle\Model\DevCycleUser; $options = new DevCycleOptions( false, $bucketingHostname, $unixSocketPath ); $devCycleClient = new DevCycleClient( sdkKey: getenv("DEVCYCLE_SERVER_SDK_KEY"), dvcOptions: $options ); $user_data = new DevCycleUser(array( "user_id"=>"my-user" )); try { $result = $apiInstance->allFeatures($user_data); print_r($result); } catch (Exception $e) { echo 'Exception when calling DevCycleClient->allFeatures: ', $e->getMessage(), PHP_EOL; }
Usage
To find usage documentation, visit our docs.
OpenFeature Support
This SDK provides an implementation of the OpenFeature Provider interface. Use the getOpenFeatureProvider()
method on the DevCycle SDK client to obtain a provider for OpenFeature.
$devCycleClient = new DevCycleClient( sdkKey: getenv("DEVCYCLE_SERVER_SDK_KEY"), dvcOptions: $options ); $api->setProvider($devCycleClient->getOpenFeatureProvider());
Advanced Options (Local Bucketing)
Because of the nature of PHP - we can't directly support local bucketing within PHP - but we have created a supporting worker that can be used to emulate the local bucketing function of low latency and high throughput. This proxy can be found here: https://github.com/devcyclehq/local-bucketing-proxy
The proxy has two modes - HTTP, and Unix sockets. The PHP SDK supports both modes, but the HTTP mode should be used for most cases.
The configuration for this proxy (in HTTP mode) is as follows (replacing the URL with the URL of the proxy):
use DevCycle\Model\DevCycleOptions;
$options = new DevCycleOptions(
enableEdgeDB: false,
bucketingApiHostname = "hostname for sdk proxy here"
);
The configuration for this proxy (in Unix socket mode) is as follows (replacing the UDS path with the path to the socket):
use DevCycle\Model\DevCycleOptions;
$options = new DevCycleOptions(
enableEdgeDB: false,
bucketingApiHostname: "http:/localhost",
unixSocketPath: "/path/to/unix/socket"
);