Giter Club home page Giter Club logo

flagsmith / flagsmith-php-client Goto Github PK

View Code? Open in Web Editor NEW
16.0 9.0 11.0 161 KB

PHP Client for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at https://www.flagsmith.com/

Home Page: https://www.flagsmith.com/

License: BSD 3-Clause "New" or "Revised" License

PHP 100.00%
feature-flags feature-flag feature-flagging feature-flaggers feature-toggles feature-toggle ci cd continous-deployment continuous-integration

flagsmith-php-client's Introduction

Packagist Version Packagist Downloads

Flagsmith PHP SDK

Flagsmith allows you to manage feature flags and remote config across multiple projects, environments and organisations.

The SDK for PHP applications for https://www.flagsmith.com/.

Requirements

The Flagsmith PHP SDK requires the following PHP extensions to be enabled. These are essentials for the library to function properly.

  • bc-math
  • gmp

Please view the documentation here to install the extensions, if you haven't already. For BC-Math and GMP.

Local Evaluation

Since PHP requests are separate, there is little benefit to use local evaluation without caching. To enable local evaluation, please set the environmentTtl value (>0) and using PSR simple cache implementation.

Adding to your project

For full documentation visit https://docs.flagsmith.com/clients/server-side.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests

Getting Help

If you encounter a bug or feature request we would like to hear about it. Before you submit an issue please search existing issues in order to prevent duplicates.

Get in touch

If you have any questions about our projects you can email [email protected].

Useful links

Website

Documentation

flagsmith-php-client's People

Contributors

bartoszbartniczak avatar benrometsch avatar crowlex avatar dabeeeenster avatar doppiogancio avatar floranpagliai avatar fzia avatar gagantrivedi avatar justinback avatar khvn26 avatar matthewelwell avatar oksana-yehorova avatar tm1000 avatar vincentlanglet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flagsmith-php-client's Issues

Identity Traits not being assigned

I've noticed weird behaviour on the identity traits (them not working at all),

when using withTraits, the traits object is set to NULL, not assigning any trait

$LoggedInID = new Identity($GLOBALS['user']['sub']);


$LoggedInID->withTraits([
	(new IdentityTrait('session_id'))->withValue($GLOBALS['guid']),
    (new IdentityTrait('email'))->withValue($GLOBALS['email']),
    (new IdentityTrait('preferred_username'))->withValue($GLOBALS['preferred_username']),
    (new IdentityTrait('route'))->withValue($GLOBALS['route']->Page),
    (new IdentityTrait('locale'))->withValue($Locale)
]);

$GLOBALS['flagsmith_identity'] = $LoggedInID;
object(Flagsmith\Models\Identity)#115 (3) { ["id":"Flagsmith\Models\Identity":private]=> string(36) "28e0577f-37eb-471a-8bb0-0c3309ed50ce" ["traits":"Flagsmith\Models\Identity":private]=> NULL ["flags":"Flagsmith\Models\Identity":private]=> NULL } 

however using withTrait, the object is set to an empty array, not containing any trait

            $AnonymousID->withTrait((new IdentityTrait('session_id'))->withValue($GLOBALS['guid']));
            $AnonymousID->withTrait((new IdentityTrait('route'))->withValue($GLOBALS['route']->Page));
            $AnonymousID->withTrait((new IdentityTrait('locale'))->withValue($Locale));
object(Flagsmith\Models\Identity)#206 (3) { ["id":"Flagsmith\Models\Identity":private]=> string(36) "b1e2a203-f4e1-93db-95c5-2dd10e5e7944" ["traits":"Flagsmith\Models\Identity":private]=> array(0) { } ["flags":"Flagsmith\Models\Identity":private]=> NULL } 

Running on the latest tag (2.0.1)

Initital value not nullable.

There currently is an issue with the $initialValue variable not being nullable, thus throwing the following exception if no default value is set in a flag

message' => 'Flagsmith\\Models\\Feature::withInitialValue(): Argument #1 ($initialValue) must be of type string, null given, called in /********/vendor/flagsmith/flagsmith-php-client/src/Flagsmith.php on line 584

Fix can be done in the Models/Feature.php by making the parameter in withInitialValue optional as well as the private variable $initialValue

public function withInitialValue(string $initialValue): self

private string $initialValue;

PR is upcoming

Possibility to implement PSRs? (Through Community submitted PR)

Hello!

Would you be willing to accept a PR that introduces PSR-18 and PSR-17, for example Guzzle and PSR-16 for example Symfony Cache to this library? This is how the unleashed client works (https://github.com/Unleash/unleash-client-php) and allows for more flexibility in the library. Additionally in terms of PSR-16 if one does not want to implement a cache they can just set the null driver so this library can actually work the same way as before it would just allow more flexibility than relying directly on CURL commands (like being able to async in PHP)

Cache getting incorrectly accessed/read

I am accessing flagsmith in a docker container via a PHP CMS and everytime after restarting I have to manually clear the cache folder (removing the cache folder via the entrypoint doesnt work aswell) due to an error that the cachedCall is null.

https://sentry.internal.jrbit.de/share/issue/4bf1cd4ca04b4cbcaca8541a37709f9e/

The cache folder is empty and after deleting it it works.

https://github.com/JRB-IT/crispcms/blob/68e313aedf9c30aa996ae10fead621acab24fe5b/cms/jrbit/class/crisp/api/Flagsmith.php#L53

Any clue on what the issue is an how to hotfix it? Running on Tag 2.1.1

Resolve `jsonSerialize` deprecation warnings

The following warning was presented for the jsonSerialize() methods on the MultivariateFeatureStateValueModelList and CollectionTrait and classes. We have temporarily resolved this in this PR by indicating that the return type will change in the next major version.

Deprecated: Return type of Flagsmith\Utils\Collections\FlagModelsList::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Create a release

Can you create a release please?

That would enable users of this package to use the version in composer.json, instead of dev-master.

Identity overrides in local evaluation mode

  1. Extend the Environment model with the identity_overrides: List[IdentityModel] field.
  2. On environment update in local evaluation mode, store overrides so they're efficiently accessed by identifier.
  3. For getIdentityFlagsFromDocument interface, use the storage above to retrieve the identity overrides. Fall back to a new IdentityModel instance if not found. If found, update traits with user-provided traits.

Refer to the following existing implementations:

Flagsmith/flagsmith-python-client#72
Flagsmith/flagsmith-java-client#142
Flagsmith/flagsmith-nodejs-client#143

Mocking routes directly from file

I saw that in ClientFixtures.php file the routes are create using the "withResponse" method.

->withResponse(new Response(200, [], self::loadFileContents('flags.json')))

FYI you can also use the "withFileResponse" method like the following

->withFileResponse(self::DATA_DIR . 'flags.json')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.