{"id":19140770,"url":"https://github.com/bestit/flagception-sdk","last_synced_at":"2026-03-27T02:44:02.644Z","repository":{"id":27992017,"uuid":"115807103","full_name":"bestit/flagception-sdk","owner":"bestit","description":"A simple and powerful feature toggle library for php.","archived":false,"fork":false,"pushed_at":"2023-02-14T18:33:44.000Z","size":63,"stargazers_count":71,"open_issues_count":6,"forks_count":19,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-06T23:17:20.593Z","etag":null,"topics":["feature","feature-flags","feature-toggle","flags","rollout","testing","toggle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bestit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-12-30T15:56:47.000Z","updated_at":"2024-11-05T01:24:53.000Z","dependencies_parsed_at":"2025-04-19T10:34:24.492Z","dependency_job_id":null,"html_url":"https://github.com/bestit/flagception-sdk","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/bestit/flagception-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestit%2Fflagception-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestit%2Fflagception-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestit%2Fflagception-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestit%2Fflagception-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bestit","download_url":"https://codeload.github.com/bestit/flagception-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestit%2Fflagception-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31011797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T02:33:22.146Z","status":"ssl_error","status_checked_at":"2026-03-27T02:33:21.763Z","response_time":164,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["feature","feature-flags","feature-toggle","flags","rollout","testing","toggle"],"created_at":"2024-11-09T07:18:44.115Z","updated_at":"2026-03-27T02:44:02.609Z","avatar_url":"https://github.com/bestit.png","language":"PHP","readme":"# Flagception\nFlagception is a simple and powerful feature toggle library.\nOnly a few lines of configuration necessary - and still very flexible and expandable.\n\n[![Latest Stable Version](https://poser.pugx.org/flagception/flagception/v/stable)](https://packagist.org/packages/flagception/flagception)\n[![Coverage Status](https://coveralls.io/repos/github/bestit/flagception-sdk/badge.svg?branch=master)](https://coveralls.io/github/bestit/flagception-sdk?branch=master)\n[![Build Status](https://travis-ci.org/bestit/flagception-sdk.svg?branch=master)](https://travis-ci.org/bestit/flagception-sdk)\n[![Total Downloads](https://poser.pugx.org/flagception/flagception/downloads)](https://packagist.org/packages/flagception/flagception)\n[![License](https://poser.pugx.org/flagception/flagception/license)](https://packagist.org/packages/flagception/flagception)\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/4423478b-f6db-4f77-bb36-0782bcdf82c0/small.png)](https://insight.sensiolabs.com/projects/4423478b-f6db-4f77-bb36-0782bcdf82c0)\n\nDownload the library\n---------------------------\n\nOpen a command console, enter your project directory and execute the\nfollowing command to download the latest stable version of this library:\n\n```console\n$ composer require flagception/flagception\n```\n\nQuick example\n---------------------------\nJust create a `FeatureManager` instance and pass your activator to start with feature toggling.\n\n```php\n// MyClass.php\nclass MyClass\n{\n    public function doSomething()\n    {\n        // The activator decide if the feature is active or not\n        // You can use your own activator if you implement the interface\n        $activator = new ArrayActivator();\n\n        $manager = new FeatureManager($activator);\n\n        if ($manager-\u003eisActive('your_feature_name')) {\n            // do something\n        }\n    }\n}\n```\n\nThe activator is the most important class and decide if the given feature is active or not. The `ArrayActivator` needs\nan array with active feature names as constructor argument. If the requested feature is in array, it will return true\notherwise false. Example:\n\n```php\n// MyClass.php\nclass MyClass\n{\n    public function doSomething()\n    {\n        $activator = new ArrayActivator([\n            'feature_abc',\n            'feature_def',\n            'feature_ghi'\n        ]);\n\n        $manager = new FeatureManager($activator);\n\n        // Will return true\n        if ($manager-\u003eisActive('feature_def')) {\n            // do something\n        }\n\n        // Will return false\n        if ($manager-\u003eisActive('feature_wxy')) {\n            // do something\n        }\n    }\n}\n```\n\nThis library ships an [ArrayActivator](docs/activator/array.md), a [ConstraintActivator](docs/activator/constraint.md), \na [EnvironmentActivator](docs/activator/environment.md), [CookieActivator](docs/activator/cookie.md) \nand a [ChainActivator](docs/activator/chain.md).\n\nIn most cases you will create your own activator (eg. for doctrine). Just implement the `FeatureActivatorInterface`.\n\nYou can use a [CacheActivator](docs/activator/cache.md) if you want to cache the result from some time intensive activators.\n\nAdvanced example\n---------------------------\nSometimes your activator needs more context for deciding if a feature is active or not. You can optionally add a context\nobject as second argument to the manager and check the context data in your activator. \n\nExample:\n```php\n// MyClass.php\nclass MyClass\n{\n    public function doSomething(User $user)\n    {\n        $activator = new YourCustomDoctrineActivator();\n\n        $manager = new FeatureManager($activator);\n        $context = new Context();\n        $context-\u003eadd('user_id', $user-\u003egetId());\n        \n        // Check the feature with context\n        if ($manager-\u003eisActive('feature_def', $context)) {\n            // do something\n        }\n        \n         // Check the feature without context (result may differ from above)\n         if ($manager-\u003eisActive('feature_def')) {\n             // do something\n         }\n    }\n}\n\n// YourCustomDoctrineActivator.php\nclass YourCustomDoctrineActivator implements FeatureActivatorInterface\n{\n    public function isActive($name, Context $context)\n    {\n        return $context-\u003eget('user_id') === 12;\n    }\n}\n```\n\nYou can also add the context data globally instead of adding the context to each feature request. Just pass a class\nwhich implement the `ContextDecoratorInterface` as second argument for the feature manager constructor:\n\n```php\n// MyClass.php\nclass MyClass\n{\n    public function doSomething(User $user)\n    {\n        $activator = new YourCustomDoctrineActivator();\n        $decorator = new ArrayDecorator([\n            'user_id' =\u003e $user-\u003egetId()\n        ]);\n\n        $manager = new FeatureManager($activator, $decorator);\n\n        // Check the feature with the global defined context         \n        if ($manager-\u003eisActive('feature_def')) {\n            // do something\n        }\n    }\n}\n\n//YourCustomDoctrineActivator.php\nclass YourCustomDoctrineActivator implements FeatureActivatorInterface\n{\n    public function isActive($name, Context $context)\n    {\n        return $context-\u003eget('user_id') === 12;\n    }\n}\n```\n\nYou can also mix both variants:\n```php\n// MyClass.php\nclass MyClass\n{\n    public function doSomething(User $user)\n    {\n        $activator = new YourCustomDoctrineActivator();\n        $decorator = new ArrayDecorator([\n            'user_id' =\u003e $user-\u003egetId()\n        ]);\n\n        $manager = new FeatureManager($activator, $decorator);\n\n        $context = new Context();\n        $context-\u003eadd('user_name', $user-\u003egetUsername());\n\n        // Check the feature with the global defined context         \n        if ($manager-\u003eisActive('feature_def', $context)) {\n            // do something\n        }\n    }\n}\n```\n\nThis library ships an [ArrayDecorator](docs/decorator/array.md) and a [ChainDecorator](docs/decorator/chain.md).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbestit%2Fflagception-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbestit%2Fflagception-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbestit%2Fflagception-sdk/lists"}