{"id":22092091,"url":"https://github.com/krakphp/symfony-rollout-rox","last_synced_at":"2025-03-23T23:44:50.797Z","repository":{"id":57009055,"uuid":"292126670","full_name":"krakphp/symfony-rollout-rox","owner":"krakphp","description":"Rollout ROX Integration with Symfony","archived":false,"fork":false,"pushed_at":"2020-11-10T15:41:16.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T06:52:19.560Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/krakphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-01T23:07:02.000Z","updated_at":"2020-11-10T15:33:25.000Z","dependencies_parsed_at":"2022-08-21T14:50:51.149Z","dependency_job_id":null,"html_url":"https://github.com/krakphp/symfony-rollout-rox","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krakphp%2Fsymfony-rollout-rox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krakphp%2Fsymfony-rollout-rox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krakphp%2Fsymfony-rollout-rox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krakphp%2Fsymfony-rollout-rox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krakphp","download_url":"https://codeload.github.com/krakphp/symfony-rollout-rox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245186922,"owners_count":20574554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-12-01T03:08:19.092Z","updated_at":"2025-03-23T23:44:50.778Z","avatar_url":"https://github.com/krakphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Symfony Rollout Rox Integration\n\nSymfony bundle integration with [CloudBees Feature Flags (Rox by Rollout) php sdk](https://github.com/rollout/rox-php).\n\n## Installation\n\nInstall with composer at `krak/symfony-rollout-rox`.\n\nIf symfony's composer install doesn't automatically register the bundle, you can do so manually:\n\n```php\n\u003c?php\n\nreturn [\n  //...\n  Krak\\SymfonyRox\\RoxBundle::class =\u003e ['all' =\u003e true],\n];\n```\n\n## Usage\n\n### Configuring the App Environment Key\n\n**Via ENV**\n\nSet the `ROLLOUT_ROX_APP_ENV_KEY` environment variable, and the system will pick up that key for configuration.\n\n**Via Parameter** \n\nThe app environment key is set in the symfony parameter `rollout_rox_app_env_key`. You can set that parameter directly in your app parameters config like:\n\n```yaml\nparameters:\n  rollout_rox_app_env_key: 'key goes here'\n```\n\n### Registering Containers\n\nThe Rox php library works by registering container objects with public properties that contain the default flags/variants for an experiment. The Rox system will automatically register your flags/variants with the rollout api/admin interface.\n\nTo create and register a container, you can implement the RoxContainer interface.\n\n```php\n\u003c?php\n\nnamespace App\\FeatureFlags;\n\nuse Krak\\SymfonyRox\\RoxContainer;\nuse Rox\\Server\\Flags\\RoxFlag;\n\nfinal class ProductContainer implements RoxContainer\n{\n    public $showQtyOnPDP;\n\n    public function __construct() {\n        $this-\u003eshowQtyOnPDP = new RoxFlag(false);\n    }\n    \n    // the namespace controls the prefix used in the rollout admin\n    // when displaying your flags or variants. Every container MUST have a unique \n    // namespace.\n    public function getNamespace(): string {\n        return 'product';\n    }\n}\n```\n\nThen to use that container in a service, you'll need to access it via the ContainerStore.\n\n```php\n\u003c?php\n\nnamespace App\\Service;\n\nuse Krak\\SymfonyRox\\RoxContainerStore;\n\nfinal class BuildPDPPrices\n{\n    private $flagsStore;\n\n    public function __construct(RoxContainerStore $flagsStore) {\n        $this-\u003eflagsStore = $flagsStore;\n    }\n\n    public function __invoke(string $productId): array {\n        $container = $this-\u003eflagsStore-\u003eget(\\App\\FeatureFlags\\ProductContainer::class);\n        return [\n            'qty' =\u003e $container-\u003eshowQtyOnPDP-\u003eisEnabled() ? 1 : null,\n            'price' =\u003e 100,\n        ];\n    }\n}\n```\n\nThe ContainerStore is needed to lazily initialize the Rox system. Not all requests will need to use a feature flag, so the bundle doesn't initialize until a container is accessed from the store. \n\n### Customizing the Rox Setup\n\n**Adjusting Rox Options**\n\nIf you just need to modify the RoxOptions that you would pass into Rox::setup, then you can setup a factory to build the RoxOptions, then add a service definition for those rox options, and then update the RoxSetup service definition arguments to accept the RoxOptions as the second parameter. \n\n**Advanced Customization**\n\nIf you want to have more flexibility on registration and setup, and any other hooks, it's best to just implement your own RoxSetup instance and then register your service for [RoxSetup](src/RoxSetup.php) instead of the default, or you could also use decoration as well, whatever works best for you. \n\nYou can checkout the [GlobalDefaultRoxSetup](src/GlobalDefaultRoxSetup.php) class to see the simple implementation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrakphp%2Fsymfony-rollout-rox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrakphp%2Fsymfony-rollout-rox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrakphp%2Fsymfony-rollout-rox/lists"}