Skip to content

Commit ab71905

Browse files
authored
prepare 3.5.0 release (#116)
1 parent a5d1306 commit ab71905

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1898
-5305
lines changed

.circleci/config.yml

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,17 @@ php-docker-template: &php-docker-template
1818
name: validate composer.json
1919
command: composer validate
2020
- run:
21-
name: install current dependencies
21+
name: install dependencies
2222
command: composer install --no-progress
2323
- run:
24-
name: run tests with current dependency versions
24+
name: run tests with highest compatible dependency versions
2525
command: vendor/bin/phpunit --log-junit ~/phpunit/junit.xml --coverage-text tests
2626
- store_test_results:
2727
path: ~/phpunit
2828
- store_artifacts:
2929
path: ~/phpunit
3030
- run:
31-
name: run tests with highest available dependency versions
32-
command: composer update --no-progress && vendor/bin/phpunit tests
33-
- run:
34-
name: run tests with lowest available dependency versions
31+
name: run tests with lowest compatible dependency versions
3532
# we skip this for 7.2 because the lowest compatible version of PHPUnit has a bug:
3633
# https://github.com/sebastianbergmann/comparator/pull/30
3734
command: |
@@ -44,18 +41,30 @@ jobs:
4441
<<: *php-docker-template
4542
docker:
4643
- image: circleci/php:5.6.34-cli-jessie
44+
- image: amazon/dynamodb-local
45+
- image: consul
46+
- image: redis
4747
test-7.0:
4848
<<: *php-docker-template
4949
docker:
5050
- image: circleci/php:7.0.28-cli-jessie
51+
- image: amazon/dynamodb-local
52+
- image: consul
53+
- image: redis
5154
test-7.1:
5255
<<: *php-docker-template
5356
docker:
5457
- image: circleci/php:7.1.15-cli-jessie
58+
- image: amazon/dynamodb-local
59+
- image: consul
60+
- image: redis
5561
test-7.2:
5662
<<: *php-docker-template
5763
docker:
5864
- image: circleci/php:7.2.3-cli-stretch
65+
- image: amazon/dynamodb-local
66+
- image: consul
67+
- image: redis
5968

6069
test-5.5: # CircleCI doesn't provide a Docker image for 5.5
6170
machine:
@@ -68,6 +77,14 @@ jobs:
6877
sudo apt-get install circleci-php-5.5.36 &&
6978
php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');" &&
7079
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
80+
- run:
81+
name: install Docker
82+
command: |
83+
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" &&
84+
sudo apt-get -q update &&
85+
sudo apt-cache policy docker-ce &&
86+
sudo apt-get -qy install docker-ce
87+
- run: sudo apt-get -qy install redis-server
7188
- checkout
7289
- run:
7390
name: validate composer.json
@@ -78,6 +95,20 @@ jobs:
7895
- run:
7996
name: run php-cs-fixer
8097
command: vendor/bin/php-cs-fixer fix --diff --dry-run --verbose
98+
- run:
99+
name: start DynamoDB
100+
command: docker run -p 8000:8000 amazon/dynamodb-local
101+
background: true
102+
- run:
103+
name: download Consul
104+
command: wget https://releases.hashicorp.com/consul/0.8.0/consul_0.8.0_linux_amd64.zip
105+
- run:
106+
name: extract Consul
107+
command: unzip consul_0.8.0_linux_amd64.zip
108+
- run:
109+
name: start Consul
110+
command: ./consul agent -dev
111+
background: true
81112
- run:
82113
name: run tests
83114
command: vendor/bin/phpunit --log-junit ~/phpunit/junit.xml --coverage-text tests

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
All notable changes to the LaunchDarkly PHP SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
44

5+
## [3.5.0] - 2019-01-30
6+
### Added:
7+
- It is now possible to use Consul or DynamoDB as a data store with `ld-relay`, similar to the existing Redis integration. See `LaunchDarkly\Integrations\Consul` and `LaunchDarkly\Integrations\DynamoDb`, and the reference guide [Using a persistent feature store](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store).
8+
- When using the Redis integration, you can specify a Redis connection timeout different from the default of 5 seconds by setting the option `redis_timeout` to the desired number of seconds. (Thanks, [jjozefowicz](https://github.com/launchdarkly/php-client/pull/113)!)
9+
- It is now possible to inject feature flags into the client from local JSON files, replacing the normal LaunchDarkly connection. This would typically be for testing purposes. See `LaunchDarkly\Integrations\Files`.
10+
- The `allFlagsState` method now accepts a new option, `detailsOnlyForTrackedFlags`, which reduces the size of the JSON representation of the flag state by omitting some metadata. Specifically, it omits any data that is normally used for generating detailed evaluation events if a flag does not have event tracking or debugging turned on.
11+
12+
### Changed:
13+
- The `feature_requester` and `event_publisher` configuration options now work differently: you can still set them to an instance of an implementation object, but you can also set them to a class or a class name (i.e. the same as the `feature_requester_class` option), or a factory function. Therefore, the `_class` versions of these options are no longer necessary. However, the old semantics still work, so you can for instance set `event_publisher_class` to `"LaunchDarkly\GuzzleEventPublisher"`, even though the new preferred way is to set `event_publisher` to `LaunchDarkly\Integrations\Guzzle::featureRequester()`.
14+
15+
### Fixed:
16+
- JSON data from `allFlagsState` is now slightly smaller even if you do not use the new option described above, because it omits the flag property for event tracking unless that property is true.
17+
- The `$_anonymous` property of the `LDUser` class was showing up as public rather than protected. (Thanks, [dstockto](https://github.com/launchdarkly/php-client/pull/114)!)
18+
519
## [3.4.1] - 2018-09-25
620
### Fixed:
721
- Improved the performance of `allFlags`/`allFlagsState` by not making redundant individual requests for prerequisite flags, when a flag is being evaluated that has prerequisites. Instead it will reuse the same flag data that it already obtained from LaunchDarkly in the "get all the flags" request.

README.md

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,71 @@ With Guzzle, you could persist your cache somewhere other than the default in-me
6464
Using LD-Relay
6565
==============
6666

67-
The LaunchDarkly Relay Proxy ([ld-relay](https://github.com/launchdarkly/ld-relay)) consumes the LaunchDarkly streaming API and can update
68-
a Redis 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 Redis store.
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).)
6968

7069
1. Set up ld-relay in [daemon-mode](https://github.com/launchdarkly/ld-relay#redis-storage-and-daemon-mode) with Redis
7170

72-
2. Require Predis as a dependency:
71+
2. Add the necessary dependency for the chosen database.
72+
73+
For Redis:
7374

7475
php composer.phar require "predis/predis:1.0.*"
7576

76-
3. Create the LDClient with the Redis feature requester as an option:
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:
7788

7889
$client = new LaunchDarkly\LDClient("your_sdk_key", [
79-
'feature_requester_class' => 'LaunchDarkly\LDDFeatureRequester',
80-
'redis_host' => 'your.redis.host',
81-
'redis_port' => 6379
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
8296
]);
8397

84-
4. 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 `GuzzleEventPublisher` with ld-relay event forwarding can be an efficient alternative to the default `curl`-based event publishing.
98+
For Consul:
8599

86100
$client = new LaunchDarkly\LDClient("your_sdk_key", [
87-
'event_publisher_class' => 'LaunchDarkly\GuzzleEventPublisher',
88-
'events_uri' => 'http://your-ldrelay-host:8030',
89-
'feature_requester_class' => 'LaunchDarkly\LDDFeatureRequester',
90-
'redis_host' => 'your.redis.host',
91-
'redis_port' => 6379
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
92106
]);
93107

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).
131+
94132
Testing
95133
-------
96134

@@ -107,7 +145,7 @@ Contributing
107145
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.
108146

109147
About LaunchDarkly
110-
-----------
148+
------------------
111149

112150
* 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:
113151
* 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.
@@ -119,9 +157,9 @@ About LaunchDarkly
119157
* [JavaScript](http://docs.launchdarkly.com/docs/js-sdk-reference "LaunchDarkly JavaScript SDK")
120158
* [PHP](http://docs.launchdarkly.com/docs/php-sdk-reference "LaunchDarkly PHP SDK")
121159
* [Python](http://docs.launchdarkly.com/docs/python-sdk-reference "LaunchDarkly Python SDK")
122-
* [Python Twisted](http://docs.launchdarkly.com/docs/python-twisted-sdk-reference "LaunchDarkly Python Twisted SDK")
123160
* [Go](http://docs.launchdarkly.com/docs/go-sdk-reference "LaunchDarkly Go SDK")
124161
* [Node.JS](http://docs.launchdarkly.com/docs/node-sdk-reference "LaunchDarkly Node SDK")
162+
* [Electron](http://docs.launchdarkly.com/docs/electron-sdk-reference "LaunchDarkly Electron SDK")
125163
* [.NET](http://docs.launchdarkly.com/docs/dotnet-sdk-reference "LaunchDarkly .Net SDK")
126164
* [Ruby](http://docs.launchdarkly.com/docs/ruby-sdk-reference "LaunchDarkly Ruby SDK")
127165
* [iOS](http://docs.launchdarkly.com/docs/ios-sdk-reference "LaunchDarkly iOS SDK")

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.4.1
1+
3.5.0

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,22 @@
1919
"psr/log": "^1.0"
2020
},
2121
"require-dev": {
22+
"aws/aws-sdk-php": "^3.86",
2223
"friendsofphp/php-cs-fixer": "~2.2.19",
2324
"guzzlehttp/guzzle": "^6.2.1",
2425
"kevinrob/guzzle-cache-middleware": "^1.4.1",
2526
"phpdocumentor/phpdocumentor": "^2.0",
2627
"phpunit/phpunit": ">=4.8.26 <5.4",
2728
"predis/predis": "^1.0",
29+
"sensiolabs/consul-php-sdk": ">=2.1 <3.0",
2830
"zendframework/zend-serializer": "^2.7"
2931
},
3032
"suggest": {
3133
"guzzlehttp/guzzle": "(^6.2.1) Required when using GuzzleEventPublisher or the default FeatureRequester",
3234
"kevinrob/guzzle-cache-middleware": "(^1.4.1) Recommended for performance when using the default FeatureRequester",
33-
"predis/predis": "(^1.0) Required when using LDDFeatureRequester"
35+
"predis/predis": "(^1.0) Required when using LDDFeatureRequester",
36+
"aws/aws-sdk-php": "(^3.86) Required when using DynamoDbFeatureRequester",
37+
"sensiolabs/consul-php-sdk": "(>=2.1 <3.0) Required when using ConsulFeatureRequester"
3438
},
3539
"autoload": {
3640
"psr-4": {

0 commit comments

Comments
 (0)