Skip to content

Commit 78d2dd2

Browse files
authored
Merge pull request #10 from eplusminus/php-5.3
update PHP 5.3 branch from master
2 parents e440463 + 82f97b7 commit 78d2dd2

27 files changed

+1355
-738
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
composer.phar
55
.vagrant
66
integration-tests/vendor
7-
integration-tests/composer.lock
7+
composer.lock

CHANGELOG.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,65 @@
11
# Change log
22

3-
All notable changes to the LaunchDarkly Java SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
3+
All notable changes to the LaunchDarkly PHP SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
4+
5+
## [2.3.0] - 2017-10-06
6+
### Added
7+
- New `flush` method forces events to be published to the LaunchDarkly service. This can be useful if `LDClient` is not automatically destroyed at the end of a request. Thanks @foxted!
8+
9+
## [2.2.0] - 2017-06-06
10+
### Added
11+
- Support for [publishing events via ld-relay](README.md#using-ld-relay)
12+
- Allow `EventPublisher` to be injected into the client.
13+
- `GuzzleEventPublisher` as a synchronous, in-process alternative to publishing events via background processes.
14+
- Allow the `curl` path used by `CurlEventPublisher` to be customized via the `curl` option to `LDClient`. Thanks @abacaphiliac!
15+
16+
## [2.1.2] - 2017-04-27
17+
### Changed
18+
- Added package suggestions in `composer.json`.
19+
20+
### Fixed
21+
- Better handling of possibly null variations. Thanks @idirouhab!
22+
23+
## [2.1.1] - 2017-04-11
24+
### Changed
25+
- Better handling of possibly null targets. Thanks @idirouhab!
26+
- Better handling of possibly null rules.
27+
28+
## [2.1.0] - 2017-03-23
29+
### Changed
30+
- Allow FeatureRequester to be injected into the client. Thanks @abacaphiliac!
31+
- Allow Predis\Client to be overriden in LDDFeatureRequester. Thanks @abacaphiliac!
32+
- Use logger interface method instead of Monolog method. Thanks @abacaphiliac!
33+
- Improve type hinting for default. Thanks @jdrieghe!
34+
35+
## [2.0.7] - 2017-03-03
36+
### Changed
37+
- Removed warning when calling `allFlags` via `LDDFeatureRequester`
38+
- Removed warning when a feature flag's prerequisites happen to be null
39+
40+
## [2.0.6] - 2017-02-07
41+
### Changed
42+
- Use minimum versions in composer.json
43+
44+
## [2.0.5] - 2017-02-03
45+
### Changed
46+
- Made Monolog dependency version less strict
47+
48+
## [2.0.4] - 2017-01-26
49+
### Changed
50+
- Made Composer requirements less strict
51+
52+
## [2.0.3] - 2017-01-05
53+
### Changed
54+
- Fixed botched 2.0.2 release: Better handling of null vs false when evaluating.
55+
56+
## [2.0.2] - 2017-01-04
57+
### Changed
58+
- Better handling of null vs false when evaluating.
59+
60+
## [2.0.1] - 2016-11-09
61+
### Added
62+
- Monolog is now a required dependency
463

564
## [2.0.0] - 2016-08-08
665
### Added
@@ -15,4 +74,4 @@ All notable changes to the LaunchDarkly Java SDK will be documented in this file
1574
- The `toggle` call has been deprecated in favor of `variation`.
1675

1776
### Removed
18-
- The `getFlag` function has been removed.
77+
- The `getFlag` function has been removed.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ We encourage pull-requests and other contributions from the community. We've als
77
This can help with getting php 5.3 on your mac: https://github.com/Homebrew/homebrew-php
88

99
To see composer dependency graph:
10-
`php composer.phar show -i -t`
10+
`php composer.phar show -i -t`

README.md

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ LaunchDarkly SDK for PHP
55

66
[![Circle CI](https://circleci.com/gh/launchdarkly/php-client.svg?style=svg)](https://circleci.com/gh/launchdarkly/php-client)
77

8+
Requirements
9+
------------
10+
1. PHP 5.3 or higher.
11+
812
Quick setup
913
-----------
1014

11-
0. Install the PHP SDK with [Composer](https://getcomposer.org/)
15+
1. Install the PHP SDK and monolog for logging with [Composer](https://getcomposer.org/)
1216

1317
php composer.phar require launchdarkly/launchdarkly-php
14-
php composer.phar require "guzzlehttp/guzzle:6.2.1"
15-
php composer.phar require "kevinrob/guzzle-cache-middleware": "1.4.1"
18+
php composer.phar require "guzzle/guzzle:dev-master#ecb935d2d0ecd8cddae4dcfb90515cac5e2cb023"
1619

1720
1. After installing, require Composer's autoloader:
1821

1922
require 'vendor/autoload.php';
2023

21-
2. Create a new LDClient with your SDK key:
24+
1. Create a new LDClient with your SDK key:
2225

2326
$client = new LaunchDarkly\LDClient("your_sdk_key");
2427

@@ -39,42 +42,66 @@ Your first feature flag
3942
Fetching flags
4043
--------------
4144

42-
There are two approaches to fetching the flag rules from LaunchDarkly:
45+
There are two distinct methods of integrating LaunchDarkly in a PHP environment.
46+
47+
* [Guzzle](https://github.com/launchdarkly/guzzle3) with its [cache plugin](https://github.com/launchdarkly/guzzle3/blob/master/docs/plugins/cache-plugin.rst) to request and cache HTTP responses in an in-memory array (default) -- note, this is a forked older version of Guzzle for PHP 5.3 compatibility
48+
* [ld-relay](https://github.com/launchdarkly/ld-relay) to retrieve and store flags in Redis (recommended)
4349

44-
* Making HTTP requests (using Guzzle)
45-
* Setting up the [ld-daemon](https://github.com/launchdarkly/ld-daemon) to store the flags in Redis
50+
We strongly recommend using the ld-relay. Per-flag caching (Guzzle method) is only intended for low-throughput environments.
4651

4752
Using Guzzle
4853
============
4954

50-
To use Guzzle it must be required as a dependency:
55+
Require Guzzle as a dependency:
5156

52-
php composer.phar require "guzzlehttp/guzzle:6.2.1"
53-
php composer.phar require "kevinrob/guzzle-cache-middleware": "1.4.1"
57+
php composer.phar require "guzzle/guzzle:dev-master#ecb935d2d0ecd8cddae4dcfb90515cac5e2cb023"
5458

5559
It will then be used as the default way of fetching flags.
5660

57-
Using Redis
58-
===========
61+
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).
5962

60-
1. Require Predis as a dependency:
63+
$client = new LaunchDarkly\LDClient("YOUR_SDK_KEY", array("cache_storage" => $cacheStorage));
6164

62-
php composer.phar require "predis/predis:1.0.*"
65+
Using LD-Relay
66+
==============
6367

64-
2. Create the LDClient with the Redis feature requester as an option:
68+
The LaunchDarkly Relay Proxy ([ld-relay](https://github.com/launchdarkly/ld-relay)) consumes the LaunchDarkly streaming API and can update
69+
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.
6570

66-
$client = new LaunchDarkly\LDClient("your_sdk_key", ['feature_requester_class' => 'LaunchDarkly\LDDFeatureRequester']);
71+
1. Set up ld-relay in [daemon-mode](https://github.com/launchdarkly/ld-relay#redis-storage-and-daemon-mode) with Redis
6772

68-
Learn more
69-
-----------
73+
2. Require Predis as a dependency:
7074

71-
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).
75+
php composer.phar require "predis/predis:1.0.*"
76+
77+
3. Create the LDClient with the Redis feature requester as an option:
78+
79+
$client = new LaunchDarkly\LDClient("your_sdk_key", [
80+
'feature_requester_class' => 'LaunchDarkly\LDDFeatureRequester',
81+
'redis_host' => 'your.redis.host',
82+
'redis_port' => 6379
83+
]);
84+
85+
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.
86+
87+
$client = new LaunchDarkly\LDClient("your_sdk_key", [
88+
'event_publisher_class' => 'LaunchDarkly\GuzzleEventPublisher',
89+
'events_uri' => 'http://your-ldrelay-host:8030',
90+
'feature_requester_class' => 'LaunchDarkly\LDDFeatureRequester',
91+
'redis_host' => 'your.redis.host',
92+
'redis_port' => 6379
93+
]);
7294

7395
Testing
7496
-------
7597

7698
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.
7799

100+
Learn more
101+
-----------
102+
103+
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).
104+
78105
Contributing
79106
------------
80107

@@ -90,19 +117,19 @@ About LaunchDarkly
90117
* Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
91118
* LaunchDarkly provides feature flag SDKs for
92119
* [Java](http://docs.launchdarkly.com/docs/java-sdk-reference "Java SDK")
93-
* [JavaScript] (http://docs.launchdarkly.com/docs/js-sdk-reference "LaunchDarkly JavaScript SDK")
94-
* [PHP] (http://docs.launchdarkly.com/docs/php-sdk-reference "LaunchDarkly PHP SDK")
95-
* [Python] (http://docs.launchdarkly.com/docs/python-sdk-reference "LaunchDarkly Python SDK")
96-
* [Go] (http://docs.launchdarkly.com/docs/go-sdk-reference "LaunchDarkly Go SDK")
97-
* [Node.JS] (http://docs.launchdarkly.com/docs/node-sdk-reference "LaunchDarkly Node SDK")
98-
* [.NET] (http://docs.launchdarkly.com/docs/dotnet-sdk-reference "LaunchDarkly .Net SDK")
99-
* [Ruby] (http://docs.launchdarkly.com/docs/ruby-sdk-reference "LaunchDarkly Ruby SDK")
100-
* [Python Twisted] (http://docs.launchdarkly.com/docs/python-twisted "LaunchDarkly Python Twisted SDK")
120+
* [JavaScript](http://docs.launchdarkly.com/docs/js-sdk-reference "LaunchDarkly JavaScript SDK")
121+
* [PHP](http://docs.launchdarkly.com/docs/php-sdk-reference "LaunchDarkly PHP SDK")
122+
* [Python](http://docs.launchdarkly.com/docs/python-sdk-reference "LaunchDarkly Python SDK")
123+
* [Python Twisted](http://docs.launchdarkly.com/docs/python-twisted-sdk-reference "LaunchDarkly Python Twisted SDK")
124+
* [Go](http://docs.launchdarkly.com/docs/go-sdk-reference "LaunchDarkly Go SDK")
125+
* [Node.JS](http://docs.launchdarkly.com/docs/node-sdk-reference "LaunchDarkly Node SDK")
126+
* [.NET](http://docs.launchdarkly.com/docs/dotnet-sdk-reference "LaunchDarkly .Net SDK")
127+
* [Ruby](http://docs.launchdarkly.com/docs/ruby-sdk-reference "LaunchDarkly Ruby SDK")
128+
* [iOS](http://docs.launchdarkly.com/docs/ios-sdk-reference "LaunchDarkly iOS SDK")
129+
* [Android](http://docs.launchdarkly.com/docs/android-sdk-reference "LaunchDarkly Android SDK")
101130
* Explore LaunchDarkly
102-
* [www.launchdarkly.com] (http://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
103-
* [docs.launchdarkly.com] (http://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDKs
104-
* [apidocs.launchdarkly.com] (http://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
105-
* [blog.launchdarkly.com] (http://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
106-
107-
108-
131+
* [launchdarkly.com](http://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
132+
* [docs.launchdarkly.com](http://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDKs
133+
* [apidocs.launchdarkly.com](http://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
134+
* [blog.launchdarkly.com](http://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
135+
* [Feature Flagging Guide](https://github.com/launchdarkly/featureflags/ "Feature Flagging Guide") for best practices and strategies

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0
1+
2.3.0

circle.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
machine:
22
php:
33
version: 5.3.25
4+
services:
5+
- redis
6+
- docker
47

58
test:
69
override:
710
# syntax check php files
811
- find ./src -name "*.php" -type f -print0 | xargs -0 -I {} php -l {}
912
- find ./tests -name "*.php" -type f -print0 | xargs -0 -I {} php -l {}
10-
- vendor/bin/phpunit tests
13+
14+
- vendor/bin/phpunit tests --coverage-text
15+
- vendor/bin/phpunit integration-tests/LDDFeatureRequesterTest.php

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@
2020
}
2121
],
2222
"require": {
23+
"monolog/monolog": "^1.6",
2324
"php": "~5.3",
24-
"guzzle/guzzle": "dev-master#ecb935d2d0ecd8cddae4dcfb90515cac5e2cb023",
25-
"psr/log": "1.0.0",
25+
"psr/log": "^1.0",
2626
"justinrainbow/json-schema": "v1.6.0"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "4.8.26",
30-
"phpdocumentor/phpdocumentor": "2.*",
31-
"predis/predis": "1.0.*",
32-
"zendframework/zend-serializer": "2.4.*"
29+
"guzzle/guzzle": "dev-master#ecb935d2d0ecd8cddae4dcfb90515cac5e2cb023",
30+
"phpunit/phpunit": ">=4.8.26 <5.0",
31+
"phpdocumentor/phpdocumentor": "^2.0",
32+
"predis/predis": "^1.0"
3333
},
3434
"suggested": {
35-
"monolog/monolog": "1.21.0",
36-
"predis/predis": "1.0.*"
35+
"guzzle/guzzle": "(^dev-master#ecb935d2d0ecd8cddae4dcfb90515cac5e2cb023) Required when using GuzzleEventPublisher or the default FeatureRequester",
36+
"predis/predis": "(^1.0) Required when using LDDFeatureRequester"
3737
},
3838
"autoload": {
3939
"psr-4": {

0 commit comments

Comments
 (0)