-
Notifications
You must be signed in to change notification settings - Fork 8
feat: FlagsmithProvider #126
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
Open
ChrisLightfootWild
wants to merge
23
commits into
open-feature:main
Choose a base branch
from
ChrisLightfootWild:provider/flagsmith
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4098a0b
Initial Flagsmith provider.
ChrisLightfootWild 9615e1e
Added split config for Flagsmith.
ChrisLightfootWild 9d23a4e
Flagsmith: added .gitattributes
ChrisLightfootWild 6793ad3
Flagsmith: handle enabled/disabled state of flags.
ChrisLightfootWild 9f09785
(ci) add Flagsmith to test matrix
ChrisLightfootWild 0485e53
(feat) Flagsmith resolveObjectValue should expect flag value to be en…
ChrisLightfootWild e754566
(feat) Flagsmith resolveObjectValue should not call json_decode on de…
ChrisLightfootWild 4bce148
(style) FlagsmithProvider linting
ChrisLightfootWild be6f4e2
(chore) remove unused Flagsmith dependencies
ChrisLightfootWild 25eaa2a
(chore) fix FlagsmithProvider complaints
ChrisLightfootWild 9d2c70e
(chore) fix FlagsmithProviderTest
ChrisLightfootWild 2a8e686
(chore) bunp Flagsmith minimum PHP version to 8.1
ChrisLightfootWild 1d9187e
(style) fix Flagsmith TestOfflineHandler
ChrisLightfootWild e0bf3b6
(test) added resolveBooleanValue tests to FlagsmithProvider
ChrisLightfootWild 381b541
(test) added resolveStringValue tests to FlagsmithProvider
ChrisLightfootWild 945fb94
(style) fix FlagsmithProviderTest trailing comma
ChrisLightfootWild a33f93c
(test) added resolveIntegerValue tests to FlagsmithProvider
ChrisLightfootWild 9b8b892
(test) added resolveFloatValue tests to FlagsmithProvider
ChrisLightfootWild f10470c
(test) added resolveObjectValue tests to FlagsmithProvider
ChrisLightfootWild 2c931b3
Update providers/Flagsmith/src/FlagsmithProvider.php
ChrisLightfootWild 69de543
chore(deps) updated flagsmith/flagsmith-php-client for FlagsmithProvider
ChrisLightfootWild 3f6fdca
fix: use correct PHP runtime in composer scripts
ChrisLightfootWild a89fa79
fix: update FlagsmithProvider supported PHP versions in README
ChrisLightfootWild File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.github/ export-ignore | ||
/.gitignore export-ignore | ||
/.readthedocs.yml export-ignore | ||
/build/ export-ignore | ||
/CHANGELOG.md export-ignore | ||
/phpcs.xml.dist export-ignore | ||
/phpstan.neon.dist export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/psalm-baseline.xml export-ignore | ||
/psalm.xml export-ignore | ||
/tests/ export-ignore | ||
|
||
* text=auto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/build | ||
/composer.lock | ||
/vendor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Changelog |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# OpenFeature Flagsmith Provider for PHP | ||
|
||
[](https://cloud-native.slack.com/archives/C0344AANLA1) | ||
[](https://packagist.org/packages/open-feature/flagsmith-provider) | ||
[](https://packagist.org/packages/open-feature/flagsmith-provider) | ||
 | ||
[](https://packagist.org/packages/open-feature/flagsmith-provider) | ||
|
||
## Overview | ||
|
||
Flagsmith provides an all-in-one platform for developing, implementing, and managing your feature flags. This repository and package provides the client side code for interacting with it via the OpenFeature PHP SDK. | ||
|
||
This package also builds on various PSRs (PHP Standards Recommendations) such as the Logger interfaces (PSR-3) and the Basic and Extended Coding Standards (PSR-1 and PSR-12). | ||
|
||
## Installation | ||
|
||
```sh | ||
composer require open-feature/flagsmith-provider | ||
``` | ||
|
||
## Usage | ||
|
||
The `FlagsmithProvider` constructor takes a configured Flagsmith client as its only argument: | ||
|
||
```php | ||
$flagsmith = new Flagsmith\Flagsmith('YOUR_FLAGSMITH_API_KEY'); | ||
|
||
OpenFeatureAPI::setProvider(new FlagsmithProvider($flagsmith)); | ||
``` | ||
|
||
## Development | ||
|
||
### PHP Versioning | ||
|
||
This library targets PHP version and newer. As long as you have any compatible version of PHP on your system you should be able to utilize the OpenFeature SDK. | ||
|
||
This package also has a `.tool-versions` file for use with PHP version managers like `asdf`. | ||
|
||
### Installation and Dependencies | ||
|
||
Install dependencies with `composer install`. | ||
|
||
We value having as few runtime dependencies as possible. The addition of any dependencies requires careful consideration and review. | ||
|
||
### Testing | ||
|
||
Run tests with `composer run test`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
{ | ||
"name": "open-feature/flagsmith-provider", | ||
"description": "The Flagsmith provider package for open-feature", | ||
"license": "Apache-2.0", | ||
"type": "library", | ||
"keywords": [ | ||
"featureflags", | ||
"featureflagging", | ||
"openfeature", | ||
"flagsmith", | ||
"provider" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "OpenFeature PHP Maintainers", | ||
"homepage": "https://github.com/orgs/open-feature/teams/php-maintainer" | ||
}, | ||
{ | ||
"name": "open-feature/php-sdk-contrib Contributors", | ||
"homepage": "https://github.com/open-feature/php-sdk-contrib/graphs/contributors" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.1", | ||
"ext-json": "*", | ||
"flagsmith/flagsmith-php-client": "^4.1", | ||
ChrisLightfootWild marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"open-feature/sdk": "^2.0" | ||
}, | ||
"require-dev": { | ||
"ergebnis/composer-normalize": "^2.25", | ||
"friendsofphp/php-cs-fixer": "^3.13", | ||
"hamcrest/hamcrest-php": "^2.0", | ||
"mdwheele/zalgo": "^0.3.1", | ||
"mockery/mockery": "^1.5", | ||
"phan/phan": "^5.4", | ||
"php-parallel-lint/php-console-highlighter": "^1.0", | ||
"php-parallel-lint/php-parallel-lint": "^1.3", | ||
"phpstan/extension-installer": "^1.1", | ||
"phpstan/phpstan": "~1.10.0", | ||
"phpstan/phpstan-mockery": "^1.0", | ||
"phpstan/phpstan-phpunit": "^1.1", | ||
"psalm/plugin-mockery": "^0.11.0", | ||
"psalm/plugin-phpunit": "^0.18.0", | ||
"ramsey/coding-standard": "^2.0.3", | ||
"ramsey/composer-repl": "^1.4", | ||
"ramsey/conventional-commits": "^1.3", | ||
"roave/security-advisories": "dev-latest", | ||
"spatie/phpunit-snapshot-assertions": "^4.2", | ||
"vimeo/psalm": "~4.30.0" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"OpenFeature\\Providers\\Flagsmith\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"OpenFeature\\Providers\\Flagsmith\\Test\\": "tests/" | ||
} | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"phpstan/extension-installer": true, | ||
"dealerdirect/phpcodesniffer-composer-installer": true, | ||
"ergebnis/composer-normalize": true, | ||
"captainhook/plugin-composer": true, | ||
"ramsey/composer-repl": true, | ||
"php-http/discovery": false | ||
}, | ||
"lock": false, | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"captainhook": { | ||
"force-install": false | ||
} | ||
}, | ||
"scripts": { | ||
"dev:analyze": [ | ||
"@dev:analyze:phpstan", | ||
"@dev:analyze:psalm" | ||
], | ||
"dev:analyze:phpstan": "phpstan analyse --ansi --debug --memory-limit=512M", | ||
"dev:analyze:psalm": "psalm", | ||
"dev:build:clean": "git clean -fX build/", | ||
"dev:grpc": [ | ||
"@dev:grpc:init", | ||
"@dev:grpc:generate", | ||
"@dev:grpc:stage" | ||
], | ||
"dev:grpc:generate": "export GOPATH=\"$(pwd)/schemas/vendor\" && pushd schemas && make gen-php && popd", | ||
"dev:grpc:init": "git submodule update --recursive", | ||
"dev:grpc:stage": "git add --force ./proto", | ||
"dev:lint": [ | ||
"@dev:lint:syntax", | ||
"@dev:lint:style" | ||
], | ||
"dev:lint:fix": "phpcbf", | ||
"dev:lint:style": "phpcs --colors", | ||
"dev:lint:syntax": "parallel-lint --colors src/ tests/", | ||
"dev:test": [ | ||
"@dev:lint", | ||
"@dev:analyze", | ||
"@dev:test:unit", | ||
"@dev:test:integration" | ||
], | ||
"dev:test:coverage:ci": "phpunit --colors=always --coverage-text --coverage-clover build/coverage/clover.xml --coverage-cobertura build/coverage/cobertura.xml --coverage-crap4j build/coverage/crap4j.xml --coverage-xml build/coverage/coverage-xml --log-junit build/junit.xml", | ||
"dev:test:coverage:html": "phpunit --colors=always --coverage-html build/coverage/coverage-html/", | ||
"dev:test:unit": "phpunit --colors=always --testdox", | ||
"dev:test:unit:debug": "phpunit --colors=always --testdox -d xdebug.profiler_enable=on", | ||
"dev:test:unit:setup": "echo 'Setup for unit tests...'", | ||
"dev:test:unit:teardown": "echo 'Tore down unit tests...'", | ||
"dev:test:integration:setup": "echo 'Setup for integration tests...'", | ||
"dev:test:integration:teardown": "echo 'Tore down integration tests...'", | ||
"test": "@dev:test" | ||
}, | ||
"scripts-descriptions": { | ||
"dev:analyze": "Runs all static analysis checks.", | ||
"dev:analyze:phpstan": "Runs the PHPStan static analyzer.", | ||
"dev:analyze:psalm": "Runs the Psalm static analyzer.", | ||
"dev:build:clean": "Cleans the build/ directory.", | ||
"dev:lint": "Runs all linting checks.", | ||
"dev:lint:fix": "Auto-fixes coding standards issues, if possible.", | ||
"dev:lint:style": "Checks for coding standards issues.", | ||
"dev:lint:syntax": "Checks for syntax errors.", | ||
"dev:test": "Runs linting, static analysis, and unit tests.", | ||
"dev:test:coverage:ci": "Runs unit tests and generates CI coverage reports.", | ||
"dev:test:coverage:html": "Runs unit tests and generates HTML coverage report.", | ||
"dev:test:unit": "Runs unit tests.", | ||
"test": "Runs linting, static analysis, and unit tests." | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0"?> | ||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> | ||
|
||
<arg name="extensions" value="php"/> | ||
<arg name="colors"/> | ||
<arg value="sp"/> | ||
|
||
<file>./src</file> | ||
<file>./tests</file> | ||
|
||
<exclude-pattern>*/tests/fixtures/*</exclude-pattern> | ||
<exclude-pattern>*/tests/*/fixtures/*</exclude-pattern> | ||
|
||
<rule ref="Ramsey"> | ||
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/> | ||
<exclude name="SlevomatCodingStandard.Classes.SuperfluousErrorNaming"/> | ||
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/> | ||
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/> | ||
<exclude name="SlevomatCodingStandard.Classes.SuperfluousTraitNaming"/> | ||
|
||
<exclude name="Generic.Files.LineLength.TooLong"/> | ||
<exclude name="Generic.Commenting.Todo.TaskFound"/> | ||
</rule> | ||
|
||
</ruleset> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
parameters: | ||
tmpDir: ./build/cache/phpstan | ||
level: max | ||
paths: | ||
- ./src | ||
- ./tests | ||
excludePaths: | ||
- */tests/fixtures/* | ||
- */tests/*/fixtures/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="./vendor/autoload.php" | ||
cacheResultFile="./build/cache/phpunit.result.cache" | ||
colors="true" | ||
verbose="true"> | ||
|
||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory>./tests/Unit</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</coverage> | ||
|
||
<php> | ||
<ini name="date.timezone" value="UTC"/> | ||
</php> | ||
|
||
</phpunit> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<files psalm-version="3.9.5@0cfe565d0afbcd31eadcc281b9017b5692911661"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<psalm xmlns="https://getpsalm.org/schema/config" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | ||
errorLevel="1" | ||
cacheDirectory="./build/cache/psalm" | ||
errorBaseline="./psalm-baseline.xml"> | ||
|
||
<projectFiles> | ||
<directory name="./src"/> | ||
<ignoreFiles> | ||
<directory name="./tests"/> | ||
<directory name="./vendor"/> | ||
</ignoreFiles> | ||
</projectFiles> | ||
|
||
</psalm> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.