Giter Site home page Giter Site logo

flagsmith / flagsmith-php-client Goto Github PK

View Code? Open in Web Editor NEW
17.0 8.0 11.0 158 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

Feature Flag, Remote Config and A/B Testing platform, Flagsmith

Stars Docker Pulls Docker Image Size Join the Discord chat Coverage Built with Depot

Flagsmith is an open source, fully featured, Feature Flag and Remote Config service. Use our hosted API, deploy to your own private cloud, or run on-premise.

Flagsmith

Flagsmith makes it easy to create and manage features flags across web, mobile, and server side applications. Just wrap a section of code with a flag, and then use Flagsmith to toggle that feature on or off for different environments, users or user segments.

Get up and running in less than a minute:

curl -o docker-compose.yml https://raw.githubusercontent.com/Flagsmith/flagsmith/main/docker-compose.yml
docker-compose -f docker-compose.yml up

The application will bootstrap an admin user, organisation, and project for you. You'll find a link to set your password in your Compose logs:

Superuser "[email protected]" created successfully.
Please go to the following page and choose a password: http://localhost:8000/password-reset/confirm/.../...

Note: This setup uses http:// for local development. If you've configured SSL for your local environment, you may use https:// instead. For any production deployment, always use https://.

Flagsmith Screenshot

Features

  • Feature flags. Release features with confidence through phased roll-outs.
  • Remote config. Easily toggle individual features on and off, and make changes without deploying new code.
  • A/B and Multivariate Testing. Use segments to run A/B and multivariate tests on new features. With segments, you can also introduce beta programs to get early user feedback.
  • Organization Management. Organizations, projects, and roles for team members help keep your deployment organized.
  • Integrations. Easily enhance Flagsmith with your favourite tools.

Trying Flagsmith

Flagsmith hosted SaaS

You can try our hosted version for free at https://flagsmith.com/

Flagsmith Open Source

The Flagsmith API is built using Python 3, Django 2, and DjangoRestFramework 3. You can try the application out using:

We also have options for deploying to AWS, GCP, Azure and On-Premise. If you need help getting up and running, please get in touch!

Overview

This repository is formed of 2 core components, the REST API (found in /api) and the web-based administrator dashboard (found in /frontend) that you can use to manage Flagsmith. Technical documentation for each component can be found at the API and Frontend pages within our Documentation

These two components run as separate applications. The web-based dashboard is a single page app that communicates via REST calls to the API.

Resources

Acknowledgements

Thank you to Uffizzi for providing ephemeral environments to preview pull requests.

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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flagsmith-php-client's Issues

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')

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.

Regex segment local evaluation with getype cast expression as int

Hello,

We encountered a bug after defining a regex segment with the following regex ^\d*[13579]$, after a lot of investigation we found that the code cast the expression as an int, making the regex useless and hazardous. We added dumps to the code in order to help you understand the bug.

class SegmentConditionModel
{
    public function matchesTraitValue($traitValue): bool
    {
        $condition = false;
        $castedValue = $this->value;
        $traitValueType = gettype($traitValue);

        dump($castedValue); // "^\d*[13579]$"
        dump($traitValueType); // "integer"
        dump($this->operator); "REGEX"
        if ($traitValueType == 'boolean') {
            $castedValue = filter_var($castedValue, FILTER_VALIDATE_BOOLEAN);
        } elseif ($this->operator === SegmentConditions::MODULO) {
            return $this->matchesModuloTraitValue($traitValue);
        } else {
            settype($castedValue, $traitValueType);
        }
        dump($castedValue); // 0
    }
}

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)

Support transient identities and traits

Update the getIdentityFlags interface to support:

  • an optional boolean transient argument to denote a transient identity.
  • an optional string list transientTraits argument to mark transient traits.

Refer to Flagsmith/flagsmith#4279 to correctly send transient identities and traits when calling the /api/v1/identities endpoint.

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)

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

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

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

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

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.