https://github.com/configcat/php-sdk
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.
https://github.com/configcat/php-sdk
configcat configuration configuration-management feature-flag feature-flags feature-toggle feature-toggles featureflags php remote-config
Last synced: 3 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/configcat/php-sdk
- Owner: configcat
- License: mit
- Created: 2018-12-26T19:28:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-02-24T09:58:21.000Z (5 months ago)
- Last Synced: 2025-04-15T21:15:09.665Z (3 months ago)
- Topics: configcat, configuration, configuration-management, feature-flag, feature-flags, feature-toggle, feature-toggles, featureflags, php, remote-config
- Language: PHP
- Homepage: https://configcat.com/docs/sdk-reference/php
- Size: 753 KB
- Stars: 21
- Watchers: 4
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# ConfigCat SDK for PHP
https://configcat.comConfigCat SDK for PHP provides easy integration for your application to ConfigCat.
ConfigCat is a feature flag and configuration management service that lets you separate releases from deployments. You can turn your features ON/OFF using ConfigCat Dashboard even after they are deployed. ConfigCat lets you target specific groups of users based on region, email or any other custom user attribute.
ConfigCat is a hosted feature flag service. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
[](https://github.com/configcat/php-sdk/actions/workflows/php-ci.yml)
[](https://packagist.org/packages/configcat/configcat-client)
[](https://packagist.org/packages/configcat/configcat-client)
[](https://sonarcloud.io/project/overview?id=configcat_php-sdk)
[](https://sonarcloud.io/project/overview?id=configcat_php-sdk)## Requirements
- PHP >= 8.1ConfigCat SDK for PHP >= 7.1 is available [here](https://github.com/configcat/php7-sdk).
## Getting started
### 1. Install the package with [Composer](https://getcomposer.org/)
```shell
composer require configcat/configcat-client
```### 2. Go to the ConfigCat Dashboard to get your *SDK Key*:
### 3. Create the *ConfigCat* client instance
```php
$client = new \ConfigCat\ConfigCatClient("#YOUR-SDK-KEY#");
```### 4. Get your setting value:
```php
$isMyAwesomeFeatureEnabled = $client->getValue("isMyAwesomeFeatureEnabled", false);
if(is_bool($isMyAwesomeFeatureEnabled) && $isMyAwesomeFeatureEnabled) {
doTheNewThing();
} else {
doTheOldThing();
}
```## Getting user specific setting values with Targeting
Using this feature, you will be able to get different setting values for different users in your application by passing a `User Object` to the `getValue()` function.Read more about [Targeting here](https://configcat.com/docs/advanced/targeting/).
## User object
Percentage and targeted rollouts are calculated by the user object you can optionally pass to the configuration requests.
The user object must be created with a **mandatory** identifier parameter which should uniquely identify each user:
```php
$user = new \ConfigCat\User("#USER-IDENTIFIER#"); // mandatory$isMyAwesomeFeatureEnabled = $client->getValue("isMyAwesomeFeatureEnabled", false, $user);
if(is_bool($isMyAwesomeFeatureEnabled) && $isMyAwesomeFeatureEnabled) {
doTheNewThing();
} else {
doTheOldThing();
}
```## Sample/Demo app
* [Sample Laravel app](https://github.com/ConfigCat/php-sdk/tree/master/samples/laravel)## Need help?
https://configcat.com/support## Contributing
Contributions are welcome. For more info please read the [Contribution Guideline](CONTRIBUTING.md).## About ConfigCat
- [Official ConfigCat SDKs for other platforms](https://github.com/configcat)
- [Documentation](https://configcat.com/docs)
- [Blog](https://configcat.com/blog)