ConfigCat SDK for PHP. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
MIT License
Published by adams85 7 months ago
New features and improvements:
Throwable
object, pass it to the onError
hook handlers. (#46)forceRefresh
fails and there is a related Throwable
object, expose it in RefreshResult
via the new getErrorException
property.forceRefresh
method (to stop potential unhandled exceptions thrown by the evaluation logic from bringing down the consumer's application).Breaking changes:
getError
property to getErrorMessage
in RefreshResult
. (Low impact expected.)?Throwable
to the onError
hook handlers. (Low impact expected.)event_id
in the log message but leave it up to the actual logger implementation to choose the log message format. (Affects consumers using custom logging only.)Published by adams85 8 months ago
New features and improvements:
Throwable
object, expose it in EvaluationDetails
via the new getErrorException
property.Bug fixes:
Breaking changes (listed in the order of expected impact):
getError
property to getErrorMessage
in EvaluationDetails
.getMatchedEvaluationRule
property to getMatchedTargetingRule
and the getMatchedEvaluationPercentageRule
property to getMatchedPercentageOption
in EvaluationDetails
.ConfigCat\Attributes
to the ConfigCat\ConfigJson
namespace and update them to support config JSON schema v6.Published by z4kn4fein about 1 year ago
Ability to override the default Guzzle HTTP client with a custom one:
\ConfigCat\Http\FetchClientInterface
to give the SDK a custom \Psr\Http\Client\ClientInterface
implementation.
namespace ConfigCat\Http;
interface FetchClientInterface
{
public function getClient(): \Psr\Http\Client\ClientInterface;
public function createRequest(string $method, string $uri): \Psr\Http\Message\RequestInterface;
}
\ConfigCat\ClientOptions::FETCH_CLIENT
configuration option where the SDK accepts a custom \ConfigCat\Http\FetchClientInterface
implementation. This option defaults to \ConfigCat\Http\GuzzleFetchClient
.\ConfigCat\ClientOptions::REQUEST_OPTIONS
and \ConfigCat\ClientOptions::CUSTOM_HANDLER
configuration options have been marked as deprecated. Options for Guzzle are available through the \ConfigCat\Http\GuzzleFetchClient::create()
method:
$client = new \ConfigCat\ConfigCatClient('<SDK-KEY>', [
\ConfigCat\ClientOptions::FETCH_CLIENT => \ConfigCat\Http\GuzzleFetchClient::create([
\GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 5,
]),
]);
guzzlehttp/guzzle
was not removed yet due to minor upgrade backward compatibility. It can be moved to suggest
at the next major version bump.php-cs-fixer
linter and phpstan
static analyzer to the CI workflow. The whole project was reformatted and analyzed, this is why this PR is bigger than usual.
error_log()
. It's still replaceable with any psr/log
implementation.Published by z4kn4fein about 1 year ago
getFetchTimeUnixSeconds()
getter of EvaluationDetails
was renamed to getFetchTimeUnixMilliseconds()
and now returns the fetch time in float
Unix milliseconds.getVariationId()
/ getAllVariationIds()
methods. Alternative: getValueDetails()
/ getAllValueDetails()
Published by z4kn4fein over 1 year ago
getValueDetails()
if a non-existent flag was requested.Published by z4kn4fein over 1 year ago
BASE-URL
option was always overridden by the CDN URL from the downloaded config.json
.Published by z4kn4fein over 1 year ago
X-ConfigCat-UserAgent
HTTP header.Published by z4kn4fein almost 2 years ago
Published by z4kn4fein almost 2 years ago
setDefaultUser(user)
/ clearDefaultUser()
methods to set / remove a default user object used when there's no user passed to getValue()
/ getValueDetails()
/ getAllValues()
/ getAllVariationIds()
methods.setOffline() / setOnline()
methods to indicate whether the SDK is allowed to make HTTP calls or not. In 'offline' mode the SDK works from the cache only.onConfigChanged([String => Setting])
/ onFlagEvaluated(EvaluationDetails)
/ onError(String)
hooks. Subscription is possible on the hooks()
property of ConfigCatClient
.getValueDetails()
method to retrieve evaluation details along with the feature flag / setting value. It returns the same details that is passed to onFlagEvaluated(EvaluationDetails)
on each evaluation.forceRefresh()
method returns with a result object to indicate whether the refresh succeeded or not.ArrayCache
has a global static array now that caches the entries between each ConfigCatClient
instance. The only differentiator is the sdkKey
, so each client instance with the same sdkKey
will use the same cache entry.Published by z4kn4fein about 2 years ago
Published by z4kn4fein over 2 years ago
// Cache:
abstract protected function get(string $key); -> abstract protected function get(string $key): ?string;
abstract protected function get(string $key); -> abstract protected function set(string $key, string $value): void;
// ConfigCatClient:
function getValue($key, $defaultValue, User $user = null) -> function getValue(string $key, $defaultValue, User $user = null)
function getVariationId($key, $defaultVariationId, User $user = null) -> function getVariationId(string $key, $defaultVariationId, User $user = null)
function getAllVariationIds(User $user = null) -> function getAllVariationIds(User $user = null): array
function getKeyAndValue($variationId) -> function getKeyAndValue(string $variationId): ?Pair
function getAllKeys() -> function getAllKeys(): array
function getAllValues(User $user = null) -> function getAllValues(User $user = null): array
function forceRefresh() -> function forceRefresh(): void
Published by z4kn4fein over 2 years ago
unserialize
deprecation error. #19Published by z4kn4fein almost 3 years ago
info
level but they are now combined into a single log entry.WARNING
.NO_LOG
log level was added to turn off the logging.flag-overrides
configuration option was added to support the reading of flags & settings from a local file or an associative array.getAllValues()
function was added for evaluating all available flags.Published by z4kn4fein over 3 years ago
Update comments related to additional configuration options.
Published by z4kn4fein over 3 years ago
Fix wrong request option parameter handling for guzzle: connect-timeout
➡️ connect_timeout
.
Published by z4kn4fein over 3 years ago
Fixed wrong error message reported when the config.json download failed and simultaneously the cache was also empty. #13
Published by z4kn4fein almost 4 years ago
Added two extra client configuration options for logging:
Name | Type | Example | Description |
---|---|---|---|
log-level | int | 'log-level' => \ConfigCat\Log\LogLevel::DEBUG |
Sets the logging severity for the ConfigCat SDK. It must be a value from the constants of the \ConfigCat\Log\LogLevel class. |
exceptions-to-ignore | array | 'exceptions-to-ignore' => [InvalidOperationException::class] |
A list of exception class types that should be excluded from logging. |
Published by z4kn4fein almost 4 years ago
Add support for Guzzle v7 #9