{"id":18685441,"url":"https://github.com/wpbones/flags","last_synced_at":"2026-02-19T13:03:07.306Z","repository":{"id":257775984,"uuid":"859679777","full_name":"wpbones/flags","owner":"wpbones","description":"Flags for WP Bones","archived":false,"fork":false,"pushed_at":"2024-10-24T16:52:26.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-25T23:59:32.223Z","etag":null,"topics":["wp-bones","wp-bones-packages"],"latest_commit_sha":null,"homepage":"https://wpbones.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wpbones.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}},"created_at":"2024-09-19T05:08:47.000Z","updated_at":"2024-10-24T16:57:40.000Z","dependencies_parsed_at":"2024-09-19T08:47:01.500Z","dependency_job_id":"3fcefa1a-9fe8-40be-a044-c0f5178a71dd","html_url":"https://github.com/wpbones/flags","commit_stats":null,"previous_names":["wpbones/flags"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpbones%2Fflags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpbones%2Fflags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpbones%2Fflags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpbones%2Fflags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wpbones","download_url":"https://codeload.github.com/wpbones/flags/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223495418,"owners_count":17154716,"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":["wp-bones","wp-bones-packages"],"created_at":"2024-11-07T10:22:33.354Z","updated_at":"2025-10-19T13:54:52.916Z","avatar_url":"https://github.com/wpbones.png","language":"PHP","readme":"# Flags for WP Bones\n\n\u003cdiv align=\"center\"\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/wpbones/flags/v/stable?style=for-the-badge)](https://packagist.org/packages/wpbones/flags) \u0026nbsp;\n[![Latest Unstable Version](https://poser.pugx.org/wpbones/flags/v/unstable?style=for-the-badge)](https://packagist.org/packages/wpbones/flags) \u0026nbsp;\n[![Total Downloads](https://poser.pugx.org/wpbones/flags/downloads?style=for-the-badge)](https://packagist.org/packages/wpbones/flags) \u0026nbsp;\n[![License](https://poser.pugx.org/wpbones/flags/license?style=for-the-badge)](https://packagist.org/packages/wpbones/flags) \u0026nbsp;\n[![Monthly Downloads](https://poser.pugx.org/wpbones/flags/d/monthly?style=for-the-badge)](https://packagist.org/packages/wpbones/flags)\n\n\u003c/div\u003e\n\nFlags for [WP Bones](https://wpbones.com) is a PHP package designed for the WP Bones framework, allowing you to enable or disable features in plugins using [YAML](https://yaml.org/) configuration files.\nThis approach simplifies feature management and makes the plugin more flexible and easy to configure, even for non-technical users.\n\n## Key features\n - Enable and Disable Features: Using flags, you can easily activate or deactivate specific plugin features.\n - YAML Configuration: YAML files are easy to read and modify, and can be used to configure various plugin options.\n - Flexibility: The path and name of the YAML file can be customized through the plugin configuration.\n - Reusability: The same YAML file can be used across different plugins, improving code consistency and maintenance.\n\n## Installation\n\nYou can install third party packages by using:\n\n```sh\nphp bones require wpbones/flags\n```\n\nI advise to use this command instead of `composer require` because doing this an automatic renaming will done.\n\nYou can use composer to install this package:\n\n```sh\ncomposer require wpbones/flags\n```\n\nYou may also to add `\"wpbones/flags\": \"~0.7\"` in the `composer.json` file of your plugin:\n\n```json\n  \"require\": {\n    \"php\": \"\u003e=7.4.0\",\n    \"wpbones/wpbones\": \"~1.5\",\n    \"wpbones/flags\": \"~1.1\"\n  },\n```\n\nand run\n\n```sh\ncomposer install\n```\n\n## YAML file example\n\n```yaml\n# The version of the file is 1.0.0\nversion: \"1.0.0\"\nexample:\n  # Enable or disable the Example feature\n  enabled: true\n  # Throttle request time in minutes\n  # By setting this value to 0, the feature will be disabled\n  throttle: 5\n  # Request timeout\n  timeout: 0\n```\n\nYou can find more information about the YAML syntax in the [Symfony documentation](https://symfony.com/doc/current/components/yaml.html).\n\n## YAML file configuration path\n\nYou can creare your own YAML file everywhere in your plugin, but I suggest to create it in the `config` directory of your plugin.\n\nThe default path and filename is:\n\n```sh\nconfig/flags.yaml\n```\n\n### Set the flags path in the plugin configuration\n\nYou can set the path and filename in the plugin configuration by adding the following line in the `config/plugin.php` file of your plugin:\n\n```php\n\u003c?php\n\nif (!defined('ABSPATH')) {\n    exit();\n}\n\nreturn [\n  /*\n  |--------------------------------------------------------------------------\n  | Logging Configuration\n  |--------------------------------------------------------------------------\n  |\n  | Here you may configure the log settings for your plugin.\n  |\n  | Available Settings: \"single\", \"daily\", \"errorlog\".\n  |\n  | Set to false or 'none' to stop logging.\n  |\n  */\n\n  'log' =\u003e 'errorlog',\n\n  'log_level' =\u003e 'debug',\n\n  /*\n  |--------------------------------------------------------------------------\n  | Flags package path Configuration\n  |--------------------------------------------------------------------------\n  |\n  | Here you may configure the flags path for your plugin.\n  |\n  */\n  'flags' =\u003e [\n      'path' =\u003e 'config/flags.yaml',\n  ],\n  ...\n```\n\n## Basic usage\n\nYou can use the `wpbones_flags` helper function to get the value of a flag:\n\n```php\nwpbones_flags()-\u003eget('example.enabled', false);\n```\n\nThe first parameter is the flag name, and the second parameter is the default value if the flag is not found.\n\nYou may also use the class directly:\n\n```php\nuse WPKirk\\Flags\\Flags;\n\n$flags = new Flags();\n$flags-\u003eget('example.enabled', false);\n```\n\nor by using the static method:\n\n```php\nuse WPKirk\\Flags\\Flags;\n\nFlags::get('example.enabled', false);\n```\n\n### Set the flags path by method\n\nYou may also set/change the path by using:\n\n```php\nwpbones_flags('config/flags.yaml')-\u003eget('logger.enabled', false);\n```\n\nor the fluent method `withPath`:\n\n```php\nwpbones_flags()-\u003ewithPath('config/flags.yaml')-\u003eget('logger.enabled', false);\n```\n\nby using the class directly:\n\n```php\nuse WPKirk\\Flags\\Flags;\n\n$flags = new Flags();\n$flags-\u003ewithPath('config/flags.yaml')-\u003eget('logger.enabled', false);\n```\n\nor by using the static method:\n\n```php\nuse WPKirk\\Flags\\Flags;\n\nFlags::withPath('config/flags.yaml')-\u003eget('logger.enabled', false);\n```\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpbones%2Fflags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwpbones%2Fflags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpbones%2Fflags/lists"}