{"id":33947911,"url":"https://github.com/leettech/laravel-flagger","last_synced_at":"2026-03-27T04:07:00.042Z","repository":{"id":57013531,"uuid":"101001760","full_name":"leettech/laravel-flagger","owner":"leettech","description":"Flagger is a package that has been designed to help you on enabling feature flags in Laravel projects.","archived":false,"fork":false,"pushed_at":"2018-04-20T14:11:11.000Z","size":60,"stargazers_count":8,"open_issues_count":3,"forks_count":0,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-12-14T06:56:15.735Z","etag":null,"topics":["feature-flags","laravel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leettech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-21T23:53:14.000Z","updated_at":"2023-05-26T14:52:09.000Z","dependencies_parsed_at":"2022-08-21T13:30:11.512Z","dependency_job_id":null,"html_url":"https://github.com/leettech/laravel-flagger","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/leettech/laravel-flagger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leettech%2Flaravel-flagger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leettech%2Flaravel-flagger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leettech%2Flaravel-flagger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leettech%2Flaravel-flagger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leettech","download_url":"https://codeload.github.com/leettech/laravel-flagger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leettech%2Flaravel-flagger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31018553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T03:51:26.850Z","status":"ssl_error","status_checked_at":"2026-03-27T03:51:09.693Z","response_time":164,"last_error":"SSL_read: 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-flags","laravel","php"],"created_at":"2025-12-12T18:13:22.567Z","updated_at":"2026-03-27T04:07:00.031Z","avatar_url":"https://github.com/leettech.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Laravel Flagger\n==============\nFlagger is a package that has been designed to help you on enabling feature flags in Laravel projects.\n\n* [Version Compatibility](#version-compatibility)\n* [Installation](#installation)\n* [Configuration](#configuration)\n* [Usage](#usage)\n    * [flag](#flag)\n    * [flagMany](#flagmany)\n    * [hasFeatureEnabled](#hasfeatureenabled)\n    * [FlaggerMiddleware](#flaggermiddleware)\n    * [Getting enabled features for a model](#getting-enabled-features-for-a-model)\n* [Flagger command](#flagger-command)\n\n## Version Compatibility\n\nLaravel   | Flagger\n:---------|:----------\n 5.3.x    | 1.x.x\n 5.4.x    | 2.x.x\n\n## Installation\n\nTo install through composer, simply add the following in your `composer.json` file:\n\n```json\n{\n    \"require\": {\n        \"leettech/laravel-flagger\": \"~2.0\"\n    }\n}\n```\n\nAnd then run `composer install`.\n\n### Quick Installation\n\nThe above installation can also be simplified by using the following command:\n\n```sh\ncomposer require \"leettech/laravel-flagger=~2.0\"\n```\n\n## Configuration\n\nAfter installing the Flagger package, register the FlaggerServiceProvider in your config/app.php configuration file:\n\n```php\n'providers' =\u003e [\n    // Other service providers...\n    Leet\\Providers\\FlaggerServiceProvider::class,\n],\n```\n\nAlso, add the Flagger facade to the aliases array in your app configuration file:\n\n```php\n'aliases' =\u003e [\n    // Other aliases...\n    'Flagger' =\u003e Leet\\Facades\\Flagger::class,\n],\n```\n\nThen run the migration script to create `features` and `flaggables` tables:\n\n```sh\nphp artisan migrate\n```\n\nPublish the package configuration:\n\n```sh\nphp artisan vendor:publish --provider=\"Leet\\Providers\\FlaggerServiceProvider\"\n```\n\nAnd, in your `config/flagger.php` configuration file, specify which model will have feature flags associated to it (by default it's set to `App\\User::class`).\n\n## Usage\n\nFirst of all, make sure you have inserted your features in the `features` table in the database. You can use the model `Leet\\Models\\Feature` for this:\n\n```php\n\\Leet\\Models\\Feature::create([\n    'name' =\u003e 'notifications',\n    'description' =\u003e 'Notifications feature'\n]);\n```\n\n### flag\nUse `\\Flagger::flag($flaggable, $feature)` to attach a feature to a model:\n\n```php\n$user = \\App\\User::first();\n\\Flagger::flag($user, 'notifications');\n```\n\nYou can also add `Leet\\Models\\FlaggerTrait` to the model in order to make flagger methods available from it:\n\n```php\nclass User extends Model\n{\n    use \\Leet\\Models\\FlaggerTrait;\n}\n$user = \\App\\User::first();\n$user-\u003eflag('notifications');\n```\n\n### flagMany\nUse `\\Flagger::flagMany($flaggables, $feature)` to attach a feature to a collection of models:\n\n```php\n$users = \\App\\User::all();\n\\Flagger::flagMany($users, 'notifications');\n```\n\n### hasFeatureEnabled\n\nAnywhere in the application, you can check if a user has access to a feature:\n\n```php\nif ($user-\u003ehasFeatureEnabled('notifications')) {\n    doSomething();\n}\n```\n\n### FlaggerMiddleware\n\nTo use the FlaggerMiddleware, you have to declare it in the application kernel:\n\n```php\nprotected $routeMiddleware = [\n    // Other middleware...\n    'flagger' =\u003e \\Leet\\Middleware\\FlaggerMiddleware::class,\n];\n```\n\nAnd on any authenticated route:\n\n```php\nRoute::get('notifications', 'NotificationsController@index')-\u003emiddleware('flagger:notifications');\n```\nor\n```php\nRoute::group(['middleware' =\u003e 'flagger:notifications'], function () {\n    Route::get('notifications', 'NotificationsController@index');\n    Route::post('notifications', 'NotificationsController@store')\n});\n```\n\n### Getting enabled features for a model\n\nBy adding ```Leet\\Models\\FlaggerTrait``` to your model, you are able to access its enabled features:\n\n```php\n// returns the features a user have access to\n$user-\u003efeatures;\n```\n\n## Flagger command\n\nThe flagger command accepts an integer, array, or a path to a csv containing a list of integers and adds a flag to each of them:\n\n```sh\nphp artisan flagger notifications 1\n// OR\nphp artisan flagger notifications 1 2 3\n// OR\nphp artisan flagger notifications users.csv\n// OR\nphp artisan flagger notifications users.csv --chunk=100\n```\n\nBe sure to create the flag before attempting to add it to any entity.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleettech%2Flaravel-flagger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleettech%2Flaravel-flagger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleettech%2Flaravel-flagger/lists"}