Skip to content

Commit 52bda3e

Browse files
authored
prepare 3.5.3 release (#122)
1 parent b69b9cc commit 52bda3e

10 files changed

+311
-358
lines changed

CONTRIBUTING.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,37 @@
1-
Contributing to the LaunchDarkly SDK for PHP
2-
================================================
1+
# Contributing to the LaunchDarkly Server-Side SDK for PHP
32

4-
We encourage pull-requests and other contributions from the community. We've also published an [SDK contributor's guide](http://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work.
3+
LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work. See below for additional information on how to contribute to this SDK.
4+
5+
## Submitting bug reports and feature requests
6+
7+
The LaunchDarkly SDK team monitors the [issue tracker](https://github.com/launchdarkly/php-server-sdk/issues) in the SDK repository. Bug reports and feature requests specific to this SDK should be filed in this issue tracker. The SDK team will respond to all newly filed issues within two business days.
8+
9+
## Submitting pull requests
10+
11+
We encourage pull requests and other contributions from the community. Before submitting pull requests, ensure that all temporary or unintended code is removed. Don't worry about adding reviewers to the pull request; the LaunchDarkly SDK team will add themselves. The SDK team will acknowledge all pull requests within two business days.
12+
13+
## Build instructions
14+
15+
### Prerequisites
16+
17+
The project uses [Composer](https://getcomposer.org/).
18+
19+
### Installing dependencies
20+
21+
From the project root directory:
22+
23+
```
24+
composer install
25+
```
26+
27+
### Testing
28+
29+
To run all unit tests:
30+
31+
```
32+
phpunit
33+
```
34+
35+
By default, the full unit test suite includes live tests of the integrations for Consul, DynamoDB, and Redis. Those tests expect you to have instances of all of those databases running locally. To skip them, set the environment variable `LD_SKIP_DATABASE_TESTS=1` before running the tests.
36+
37+
It is preferable to run tests against all supported minor versions of PHP (as described in `README.md` under Requirements), or at least the lowest and highest versions, prior to submitting a pull request. However, LaunchDarkly's CI tests will run automatically against all supported versions.

README.md

Lines changed: 16 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,34 @@
1-
LaunchDarkly SDK for PHP
2-
===========================
1+
# LaunchDarkly Server-side SDK for PHP
32

4-
[![Circle CI](https://circleci.com/gh/launchdarkly/php-client.svg?style=svg)](https://circleci.com/gh/launchdarkly/php-client)
3+
[![Circle CI](https://img.shields.io/circleci/project/launchdarkly/php-server-sdk.png)](https://circleci.com/gh/launchdarkly/php-server-sdk)
54

6-
Requirements
7-
------------
8-
1. PHP 5.5 or higher.
5+
## LaunchDarkly overview
96

10-
Quick setup
11-
-----------
7+
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/docs/getting-started) using LaunchDarkly today!
8+
9+
[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly)
1210

13-
1. Install the PHP SDK and monolog for logging with [Composer](https://getcomposer.org/)
11+
## Supported PHP versions
1412

15-
php composer.phar require launchdarkly/launchdarkly-php
13+
This version of the LaunchDarkly SDK is compatible with PHP 5.5 and higher.
1614

17-
1. After installing, require Composer's autoloader:
15+
## Getting started
1816

19-
require 'vendor/autoload.php';
17+
Refer to the [SDK reference guide](https://docs.launchdarkly.com/docs/php-sdk-reference) for instructions on getting started with using the SDK.
2018

21-
1. Create a new LDClient with your SDK key:
19+
## Learn more
2220

23-
$client = new LaunchDarkly\LDClient("your_sdk_key");
24-
25-
Your first feature flag
26-
-----------------------
27-
28-
1. Create a new feature flag on your [dashboard](https://app.launchdarkly.com)
29-
30-
2. In your application code, use the feature's key to check whether the flag is on for each user:
31-
32-
$user = new LaunchDarkly\LDUser("user@test.com");
33-
if ($client->variation("your.flag.key", $user)) {
34-
# application code to show the feature
35-
} else {
36-
# the code to run if the feature is off
37-
}
38-
39-
Fetching flags
40-
--------------
41-
42-
There are two distinct methods of integrating LaunchDarkly in a PHP environment.
43-
44-
* [Guzzle Cache Middleware](https://github.com/Kevinrob/guzzle-cache-middleware) to request and cache HTTP responses in an in-memory array (default)
45-
* [ld-relay](https://github.com/launchdarkly/ld-relay) to retrieve and store flags in Redis (recommended)
46-
47-
We strongly recommend using the ld-relay. Per-flag caching (Guzzle method) is only intended for low-throughput environments.
48-
49-
Using Guzzle
50-
============
51-
52-
Require Guzzle as a dependency:
53-
54-
php composer.phar require "guzzlehttp/guzzle:6.2.1"
55-
php composer.phar require "kevinrob/guzzle-cache-middleware:1.4.1"
56-
57-
It will then be used as the default way of fetching flags.
58-
59-
With Guzzle, you could persist your cache somewhere other than the default in-memory store, like Memcached or Redis. You could then specify your cache when initializing the client with the [cache option](https://github.com/launchdarkly/php-client/blob/master/src/LaunchDarkly/LDClient.php#L44).
60-
61-
$client = new LaunchDarkly\LDClient("YOUR_SDK_KEY", array("cache" => $cacheStorage));
62-
63-
64-
Using LD-Relay
65-
==============
66-
67-
The LaunchDarkly Relay Proxy ([ld-relay](https://github.com/launchdarkly/ld-relay)) consumes the LaunchDarkly streaming API and can update a database cache operating in your production environment. The ld-relay offers many benefits such as performance and feature flag consistency. With PHP applications, we strongly recommend setting up ld-relay with a database store. The database can be Redis, Consul, or DynamoDB. (For more about using LaunchDarkly with databases, see the [SDK reference guide](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store).)
68-
69-
1. Set up ld-relay in [daemon-mode](https://github.com/launchdarkly/ld-relay#redis-storage-and-daemon-mode) with Redis
70-
71-
2. Add the necessary dependency for the chosen database.
72-
73-
For Redis:
74-
75-
php composer.phar require "predis/predis:1.0.*"
76-
77-
For Consul:
78-
79-
php composer.phar require "sensiolabs/consul-php-sdk:2.*"
80-
81-
For DynamoDB:
82-
83-
php composer.phar require "aws/aws-sdk-php:3.*"
84-
85-
3. Create the LDClient with the appropriate parameters for the chosen database. These examples show all of the available options.
86-
87-
For Redis:
88-
89-
$client = new LaunchDarkly\LDClient("your_sdk_key", [
90-
'feature_requester' => LaunchDarkly\Integrations\Redis::featureRequester(),
91-
'redis_host' => 'your.redis.host', // defaults to "localhost" if not specified
92-
'redis_port' => 6379, // defaults to 6379 if not specified
93-
'redis_timeout' => 5, // connection timeout in seconds; defaults to 5
94-
'redis_prefix' => 'env1' // corresponds to the prefix setting in ld-relay
95-
'predis_client' => $myClient // use this if you have already configured a Predis client instance
96-
]);
97-
98-
For Consul:
99-
100-
$client = new LaunchDarkly\LDClient("your_sdk_key", [
101-
'feature_requester' => LaunchDarkly\Integrations\Consul::featureRequester(),
102-
'consul_uri' => 'http://localhost:8500', // this is the default
103-
'consul_prefix' => 'env1', // corresponds to the prefix setting in ld-relay
104-
'consul_options' => array(), // you may pass any options supported by the Guzzle client
105-
'apc_expiration' => 30 // expiration time for local caching, if you have apcu installed
106-
]);
107-
108-
For DynamoDB:
109-
110-
$client = new LaunchDarkly\LDClient("your_sdk_key", [
111-
'feature_requester' => LaunchDarkly\Integrations\DynamoDb::featureRequester(),
112-
'dynamodb_table' => 'your.table.name', // required
113-
'dynamodb_prefix' => 'env1', // corresponds to the prefix setting in ld-relay
114-
'dynamodb_options' => array(), // you may pass any options supported by the AWS SDK
115-
'apc_expiration' => 30 // expiration time for local caching, if you have apcu installed
116-
]);
117-
118-
4. If you are using DynamoDB, you must create your table manually. It must have a partition key called "namespace", and a sort key called "key" (both strings). Note that by default the AWS SDK will attempt to get your AWS credentials and region from environment variables and/or local configuration files, but you may also specify them in `dynamodb_options`.
119-
120-
5. If ld-relay is configured for [event forwarding](https://github.com/launchdarkly/ld-relay#event-forwarding), you can configure the LDClient to publish events to ld-relay instead of directly to `events.launchdarkly.com`. Using the `Guzzle` implementation of event publishing with ld-relay event forwarding can be an efficient alternative to the default `curl`-based event publishing.
121-
122-
To forward events, add the following configuration properties to the configuration shown above:
123-
124-
'event_publisher' => LaunchDarkly\Integrations\Guzzle::eventPublisher(),
125-
'events_uri' => 'http://your-ldrelay-host:8030'
126-
127-
Using flag data from a file
128-
---------------------------
129-
130-
For testing purposes, the SDK can be made to read feature flag state from a file or files instead of connecting to LaunchDarkly. See [`LaunchDarkly\Integrations\Files`](https://github.com/launchdarkly/php-client/blob/master/src/LaunchDarkly/Integrations/Files.php) and ["Reading flags from a file"](https://docs.launchdarkly.com/docs/reading-flags-from-a-file).
21+
Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](http://docs.launchdarkly.com/docs/php-sdk-reference).
13122

132-
Testing
133-
-------
23+
## Testing
13424

13525
We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs, as well as test networking behavior in a long-running application. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly.
13626

137-
Learn more
138-
-----------
139-
140-
Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](http://docs.launchdarkly.com/docs/php-sdk-reference).
141-
142-
Contributing
143-
------------
27+
## Contributing
14428

145-
We encourage pull-requests and other contributions from the community. We've also published an [SDK contributor's guide](http://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work.
29+
We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK.
14630

147-
About LaunchDarkly
148-
------------------
31+
## About LaunchDarkly
14932

15033
* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
15134
* Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"launchdarkly",
66
"launchdarkly php"
77
],
8-
"homepage": "https://github.com/launchdarkly/php-client",
8+
"homepage": "https://github.com/launchdarkly/php-server-sdk",
99
"license": "Apache-2.0",
1010
"authors": [
1111
{

scripts/release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# When done you should commit and push the changes made.
1111

1212
set -uxe
13-
echo "Starting php-client release (version update only)"
13+
echo "Starting php-server-sdk release (version update only)"
1414

1515
VERSION=$1
1616

@@ -22,4 +22,4 @@ LDCLIENT_PHP_TEMP=./LDClient.php.tmp
2222
sed "s/const VERSION = '.*'/const VERSION = '${VERSION}'/g" $LDCLIENT_PHP > $LDCLIENT_PHP_TEMP
2323
mv $LDCLIENT_PHP_TEMP $LDCLIENT_PHP
2424

25-
echo "Done with php-client release (version update only)"
25+
echo "Done with php-server-sdk release (version update only)"

tests/ConsulFeatureRequesterTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ class ConsulFeatureRequesterTest extends FeatureRequesterTestBase
1515

1616
public static function setUpBeforeClass()
1717
{
18-
$sf = new ServiceFactory();
19-
self::$kvClient = $sf->get('kv');
18+
if (!static::isSkipDatabaseTests()) {
19+
$sf = new ServiceFactory();
20+
self::$kvClient = $sf->get('kv');
21+
}
22+
}
23+
24+
protected function isDatabaseTest()
25+
{
26+
return true;
2027
}
2128

2229
protected function makeRequester()

tests/DynamoDbFeatureRequesterTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ class DynamoDbFeatureRequesterTest extends FeatureRequesterTestBase
1515

1616
public static function setUpBeforeClass()
1717
{
18-
self::$dynamoDbClient = new DynamoDbClient(self::makeDynamoDbOptions());
19-
self::createTableIfNecessary();
18+
if (!static::isSkipDatabaseTests()) {
19+
self::$dynamoDbClient = new DynamoDbClient(self::makeDynamoDbOptions());
20+
self::createTableIfNecessary();
21+
}
22+
}
23+
24+
protected function isDatabaseTest()
25+
{
26+
return true;
2027
}
2128

2229
private static function makeDynamoDbOptions()

0 commit comments

Comments
 (0)