Skip to content

prepare 3.5.0 release #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 85 commits into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
aa34e8b
fix version string
eli-darkly Jul 16, 2018
6a08f47
Merge pull request #26 from launchdarkly/3.2.1
eli-darkly Jul 16, 2018
0d4fc33
add new version of allFlags() that captures more metadata
eli-darkly Aug 20, 2018
0f76969
linter
eli-darkly Aug 20, 2018
9023ea6
missing array key guard
eli-darkly Aug 21, 2018
e215364
missing array key guards
eli-darkly Aug 21, 2018
30e9e3c
use the standard method for specifying custom JSON serialization
eli-darkly Aug 21, 2018
775f0a1
indents
eli-darkly Aug 21, 2018
c1ac079
Merge pull request #27 from launchdarkly/eb/ch22308/all-flags-state
eli-darkly Aug 21, 2018
2f80b4c
add ability to filter for client-side flags only
eli-darkly Aug 21, 2018
fd08375
fix test to fill in all required flag fields
eli-darkly Aug 21, 2018
42c1ff2
Merge pull request #28 from launchdarkly/eb/ch12124/client-side-filter
eli-darkly Aug 22, 2018
2e9829c
implement evaluation with explanations
eli-darkly Aug 24, 2018
5d8e2b0
add another evaluation test
eli-darkly Aug 24, 2018
1977097
linter
eli-darkly Aug 24, 2018
54759db
fix test method
eli-darkly Aug 25, 2018
5038b0d
Merge branch 'master' of github.com:launchdarkly/php-client
eli-darkly Aug 25, 2018
87417f1
Merge branch 'master' of github.com:launchdarkly/php-client
eli-darkly Aug 27, 2018
07eb1a7
Merge branch 'explanation' into eb/ch19976/explanations
eli-darkly Aug 29, 2018
39d5105
fix for ch22995 - include prereq value in event even if prereq is off
eli-darkly Aug 29, 2018
8391618
Merge pull request #29 from launchdarkly/eb/ch19976/explanations
eli-darkly Sep 4, 2018
180679f
cache flag data in allFlags
eli-darkly Sep 24, 2018
15720d0
rm unused imports
eli-darkly Sep 24, 2018
dd7f268
Merge pull request #30 from launchdarkly/eb/ch24369/all-flags-caching
eli-darkly Sep 25, 2018
08572c9
Merge branch 'master' of github.com:launchdarkly/php-client
eli-darkly Sep 25, 2018
d3c3932
Merge branch 'master' of github.com:launchdarkly/php-client
eli-darkly Sep 26, 2018
a2598c7
add option to reduce front-end metadata for untracked flags
eli-darkly Oct 5, 2018
78ed55f
Merge pull request #31 from launchdarkly/eb/ch24449/less-metadata
eli-darkly Nov 8, 2018
440a2ad
Merge branch 'master' of github.com:launchdarkly/php-client
eli-darkly Nov 21, 2018
7543cf3
Merge branch 'master' of github.com:launchdarkly/php-client
eli-darkly Nov 26, 2018
37e7eaf
add ability to load flags from a file
eli-darkly Jan 10, 2019
4b2f9ef
linter
eli-darkly Jan 10, 2019
226fd95
data completeness
eli-darkly Jan 10, 2019
e997d9f
more data fixes
eli-darkly Jan 10, 2019
804a170
more data fixes
eli-darkly Jan 10, 2019
5f74cb2
more data fixes
eli-darkly Jan 10, 2019
4587c04
readme link
eli-darkly Jan 10, 2019
4ae2bd9
rm unused parameters
eli-darkly Jan 10, 2019
529ec43
fix incorrect doc comment
eli-darkly Jan 10, 2019
96dc0b4
add DynamoDB integration
eli-darkly Jan 23, 2019
ea3268e
fix test config
eli-darkly Jan 23, 2019
5da57f3
fix string check
eli-darkly Jan 23, 2019
aa62488
readme
eli-darkly Jan 23, 2019
d8bcfbb
fix test data
eli-darkly Jan 23, 2019
895aa33
factor out base class, implement caching, make configuration simpler
eli-darkly Jan 23, 2019
10662d5
fix comment
eli-darkly Jan 23, 2019
2ee0e9e
rm unused const
eli-darkly Jan 23, 2019
1eeb153
can't scope constants
eli-darkly Jan 23, 2019
c82b7c7
linter
eli-darkly Jan 23, 2019
6aead62
add Consul integration
eli-darkly Jan 23, 2019
3887732
typo
eli-darkly Jan 24, 2019
10e0daf
regenerate lockfile using PHP 5.5
eli-darkly Jan 24, 2019
2ea5c52
Merge pull request #32 from launchdarkly/eb/ch26319/file-data-source
eli-darkly Jan 24, 2019
200229c
we need at least version 2.1 of the Consul package
eli-darkly Jan 24, 2019
1a7cd19
update lockfile
eli-darkly Jan 24, 2019
d2461d2
Merge branch 'master' into eb/ch28330/dynamodb
eli-darkly Jan 24, 2019
dd92f7f
Merge branch 'eb/ch28330/dynamodb' into eb/ch28432/consul
eli-darkly Jan 24, 2019
313a473
rm comment
eli-darkly Jan 24, 2019
2580f6f
remove lockfile
eli-darkly Jan 24, 2019
72f0ac8
add delay for creating test table
eli-darkly Jan 24, 2019
546bc1c
Merge branch 'eb/ch28330/dynamodb' into eb/ch28432/consul
eli-darkly Jan 24, 2019
fd536a5
move feature requester code into Integrations namespace
eli-darkly Jan 24, 2019
a8c1647
linter
eli-darkly Jan 24, 2019
f192e9a
misc test fixes
eli-darkly Jan 24, 2019
d1a2e41
Merge pull request #35 from launchdarkly/eb/ch30532/lockfile
eli-darkly Jan 25, 2019
c7f98fd
fix apc/apcu calls
eli-darkly Jan 25, 2019
9ff5c89
Merge branch 'master' into eb/ch28330/dynamodb
eli-darkly Jan 25, 2019
088aef2
Merge pull request #33 from launchdarkly/eb/ch28330/dynamodb
eli-darkly Jan 25, 2019
6f05a0f
Merge branch 'master' into eb/ch28432/consul
eli-darkly Jan 25, 2019
a49b3c1
fix comment
eli-darkly Jan 25, 2019
22498a0
Merge branch 'eb/ch28432/consul' into eb/ch30533/feature-requesters
eli-darkly Jan 25, 2019
24cf9e0
fix deprecated caching store classes
eli-darkly Jan 25, 2019
a9100fc
better caching abstraction
eli-darkly Jan 25, 2019
80a653b
typo
eli-darkly Jan 25, 2019
47c1bc2
linter
eli-darkly Jan 25, 2019
f6cf050
fix namespaces
eli-darkly Jan 25, 2019
55dd858
fix tests
eli-darkly Jan 25, 2019
17cca84
Merge pull request #36 from launchdarkly/eb/ch28432/consul
eli-darkly Jan 25, 2019
528fc91
doc fixes
eli-darkly Jan 25, 2019
68c81fb
move a bunch more stuff
eli-darkly Jan 26, 2019
613f881
misc cleanup
eli-darkly Jan 26, 2019
6d37fdd
add test for not having any flags
eli-darkly Jan 26, 2019
4014e19
restore documentation for deprecated properties
eli-darkly Jan 31, 2019
15b780d
Merge pull request #37 from launchdarkly/eb/ch30533/feature-requesters
eli-darkly Jan 31, 2019
86bc30f
version 3.5.0
eli-darkly Jan 31, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@ php-docker-template: &php-docker-template
name: validate composer.json
command: composer validate
- run:
name: install current dependencies
name: install dependencies
command: composer install --no-progress
- run:
name: run tests with current dependency versions
name: run tests with highest compatible dependency versions
command: vendor/bin/phpunit --log-junit ~/phpunit/junit.xml --coverage-text tests
- store_test_results:
path: ~/phpunit
- store_artifacts:
path: ~/phpunit
- run:
name: run tests with highest available dependency versions
command: composer update --no-progress && vendor/bin/phpunit tests
- run:
name: run tests with lowest available dependency versions
name: run tests with lowest compatible dependency versions
# we skip this for 7.2 because the lowest compatible version of PHPUnit has a bug:
# https://github.com/sebastianbergmann/comparator/pull/30
command: |
Expand All @@ -44,18 +41,30 @@ jobs:
<<: *php-docker-template
docker:
- image: circleci/php:5.6.34-cli-jessie
- image: amazon/dynamodb-local
- image: consul
- image: redis
test-7.0:
<<: *php-docker-template
docker:
- image: circleci/php:7.0.28-cli-jessie
- image: amazon/dynamodb-local
- image: consul
- image: redis
test-7.1:
<<: *php-docker-template
docker:
- image: circleci/php:7.1.15-cli-jessie
- image: amazon/dynamodb-local
- image: consul
- image: redis
test-7.2:
<<: *php-docker-template
docker:
- image: circleci/php:7.2.3-cli-stretch
- image: amazon/dynamodb-local
- image: consul
- image: redis

test-5.5: # CircleCI doesn't provide a Docker image for 5.5
machine:
Expand All @@ -68,6 +77,14 @@ jobs:
sudo apt-get install circleci-php-5.5.36 &&
php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');" &&
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
- run:
name: install Docker
command: |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" &&
sudo apt-get -q update &&
sudo apt-cache policy docker-ce &&
sudo apt-get -qy install docker-ce
- run: sudo apt-get -qy install redis-server
- checkout
- run:
name: validate composer.json
Expand All @@ -78,6 +95,20 @@ jobs:
- run:
name: run php-cs-fixer
command: vendor/bin/php-cs-fixer fix --diff --dry-run --verbose
- run:
name: start DynamoDB
command: docker run -p 8000:8000 amazon/dynamodb-local
background: true
- run:
name: download Consul
command: wget https://releases.hashicorp.com/consul/0.8.0/consul_0.8.0_linux_amd64.zip
- run:
name: extract Consul
command: unzip consul_0.8.0_linux_amd64.zip
- run:
name: start Consul
command: ./consul agent -dev
background: true
- run:
name: run tests
command: vendor/bin/phpunit --log-junit ~/phpunit/junit.xml --coverage-text tests
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

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

## [3.5.0] - 2019-01-30
### Added:
- 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).
- 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)!)
- 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`.
- 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.

### Changed:
- 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()`.

### Fixed:
- 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.
- 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)!)

## [3.4.1] - 2018-09-25
### Fixed:
- 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.
Expand Down
68 changes: 53 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,71 @@ With Guzzle, you could persist your cache somewhere other than the default in-me
Using LD-Relay
==============

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

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

2. Require Predis as a dependency:
2. Add the necessary dependency for the chosen database.

For Redis:

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

3. Create the LDClient with the Redis feature requester as an option:
For Consul:

php composer.phar require "sensiolabs/consul-php-sdk:2.*"

For DynamoDB:

php composer.phar require "aws/aws-sdk-php:3.*"

3. Create the LDClient with the appropriate parameters for the chosen database. These examples show all of the available options.

For Redis:

$client = new LaunchDarkly\LDClient("your_sdk_key", [
'feature_requester_class' => 'LaunchDarkly\LDDFeatureRequester',
'redis_host' => 'your.redis.host',
'redis_port' => 6379
'feature_requester' => LaunchDarkly\Integrations\Redis::featureRequester(),
'redis_host' => 'your.redis.host', // defaults to "localhost" if not specified
'redis_port' => 6379, // defaults to 6379 if not specified
'redis_timeout' => 5, // connection timeout in seconds; defaults to 5
'redis_prefix' => 'env1' // corresponds to the prefix setting in ld-relay
'predis_client' => $myClient // use this if you have already configured a Predis client instance
]);

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.
For Consul:

$client = new LaunchDarkly\LDClient("your_sdk_key", [
'event_publisher_class' => 'LaunchDarkly\GuzzleEventPublisher',
'events_uri' => 'http://your-ldrelay-host:8030',
'feature_requester_class' => 'LaunchDarkly\LDDFeatureRequester',
'redis_host' => 'your.redis.host',
'redis_port' => 6379
'feature_requester' => LaunchDarkly\Integrations\Consul::featureRequester(),
'consul_uri' => 'http://localhost:8500', // this is the default
'consul_prefix' => 'env1', // corresponds to the prefix setting in ld-relay
'consul_options' => array(), // you may pass any options supported by the Guzzle client
'apc_expiration' => 30 // expiration time for local caching, if you have apcu installed
]);

For DynamoDB:

$client = new LaunchDarkly\LDClient("your_sdk_key", [
'feature_requester' => LaunchDarkly\Integrations\DynamoDb::featureRequester(),
'dynamodb_table' => 'your.table.name', // required
'dynamodb_prefix' => 'env1', // corresponds to the prefix setting in ld-relay
'dynamodb_options' => array(), // you may pass any options supported by the AWS SDK
'apc_expiration' => 30 // expiration time for local caching, if you have apcu installed
]);

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`.

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.

To forward events, add the following configuration properties to the configuration shown above:

'event_publisher' => LaunchDarkly\Integrations\Guzzle::eventPublisher(),
'events_uri' => 'http://your-ldrelay-host:8030'

Using flag data from a file
---------------------------

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).

Testing
-------

Expand All @@ -107,7 +145,7 @@ Contributing
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.

About LaunchDarkly
-----------
------------------

* 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:
* 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.
Expand All @@ -119,9 +157,9 @@ About LaunchDarkly
* [JavaScript](http://docs.launchdarkly.com/docs/js-sdk-reference "LaunchDarkly JavaScript SDK")
* [PHP](http://docs.launchdarkly.com/docs/php-sdk-reference "LaunchDarkly PHP SDK")
* [Python](http://docs.launchdarkly.com/docs/python-sdk-reference "LaunchDarkly Python SDK")
* [Python Twisted](http://docs.launchdarkly.com/docs/python-twisted-sdk-reference "LaunchDarkly Python Twisted SDK")
* [Go](http://docs.launchdarkly.com/docs/go-sdk-reference "LaunchDarkly Go SDK")
* [Node.JS](http://docs.launchdarkly.com/docs/node-sdk-reference "LaunchDarkly Node SDK")
* [Electron](http://docs.launchdarkly.com/docs/electron-sdk-reference "LaunchDarkly Electron SDK")
* [.NET](http://docs.launchdarkly.com/docs/dotnet-sdk-reference "LaunchDarkly .Net SDK")
* [Ruby](http://docs.launchdarkly.com/docs/ruby-sdk-reference "LaunchDarkly Ruby SDK")
* [iOS](http://docs.launchdarkly.com/docs/ios-sdk-reference "LaunchDarkly iOS SDK")
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.1
3.5.0
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@
"psr/log": "^1.0"
},
"require-dev": {
"aws/aws-sdk-php": "^3.86",
"friendsofphp/php-cs-fixer": "~2.2.19",
"guzzlehttp/guzzle": "^6.2.1",
"kevinrob/guzzle-cache-middleware": "^1.4.1",
"phpdocumentor/phpdocumentor": "^2.0",
"phpunit/phpunit": ">=4.8.26 <5.4",
"predis/predis": "^1.0",
"sensiolabs/consul-php-sdk": ">=2.1 <3.0",
"zendframework/zend-serializer": "^2.7"
},
"suggest": {
"guzzlehttp/guzzle": "(^6.2.1) Required when using GuzzleEventPublisher or the default FeatureRequester",
"kevinrob/guzzle-cache-middleware": "(^1.4.1) Recommended for performance when using the default FeatureRequester",
"predis/predis": "(^1.0) Required when using LDDFeatureRequester"
"predis/predis": "(^1.0) Required when using LDDFeatureRequester",
"aws/aws-sdk-php": "(^3.86) Required when using DynamoDbFeatureRequester",
"sensiolabs/consul-php-sdk": "(>=2.1 <3.0) Required when using ConsulFeatureRequester"
},
"autoload": {
"psr-4": {
Expand Down
Loading