{"id":20876066,"url":"https://github.com/php-casbin/workerman-redis-watcher","last_synced_at":"2025-10-04T00:53:51.782Z","repository":{"id":44930824,"uuid":"426185273","full_name":"php-casbin/workerman-redis-watcher","owner":"php-casbin","description":"Workerman Redis watcher for PHP-Casbin","archived":false,"fork":false,"pushed_at":"2024-10-29T16:15:35.000Z","size":10,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-01T07:38:44.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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-casbin.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":"2021-11-09T10:29:41.000Z","updated_at":"2024-10-29T16:15:40.000Z","dependencies_parsed_at":"2022-08-27T22:00:24.197Z","dependency_job_id":null,"html_url":"https://github.com/php-casbin/workerman-redis-watcher","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/php-casbin%2Fworkerman-redis-watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Fworkerman-redis-watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Fworkerman-redis-watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Fworkerman-redis-watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-casbin","download_url":"https://codeload.github.com/php-casbin/workerman-redis-watcher/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253765946,"owners_count":21960821,"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-11-18T06:49:55.864Z","updated_at":"2025-10-04T00:53:46.743Z","avatar_url":"https://github.com/php-casbin.png","language":"PHP","readme":"# Workerman Redis watcher for PHP-Casbin\n\n[![Latest Stable Version](https://poser.pugx.org/casbin/workerman-redis-watcher/v/stable)](https://packagist.org/packages/casbin/workerman-redis-watcher)\n[![Total Downloads](https://poser.pugx.org/casbin/workerman-redis-watcher/downloads)](https://packagist.org/packages/casbin/workerman-redis-watcher)\n[![License](https://poser.pugx.org/casbin/workerman-redis-watcher/license)](https://packagist.org/packages/casbin/workerman-redis-watcher)\n\n[Workerman Redis](https://github.com/walkor/redis) watcher for [PHP-Casbin](https://github.com/php-casbin/php-casbin), [Casbin](https://casbin.org/) is a powerful and efficient open-source access control library.\n\n### Installation\n\nVia [Composer](https://getcomposer.org/).\n\n```\ncomposer require casbin/workerman-redis-watcher\n```\n\n### Usage\n\n```php\n\nrequire dirname(__FILE__) . '/../vendor/autoload.php';\n\nuse Casbin\\Enforcer;\nuse CasbinWatcher\\WorkermanRedis\\Watcher;\nuse Workerman\\Worker;\n\n\n$worker = new Worker();\n$worker-\u003ecount = 2;\n$worker-\u003eonWorkerStart = function () {\n\n    // Initialize the Watcher.\n    $watcher = new Watcher([\n        'host' =\u003e '127.0.0.1',\n        'password' =\u003e '',\n        'port' =\u003e 6379,\n        'database' =\u003e 0,\n    ]);\n\n    // Initialize the Enforcer.\n    $enforcer = new Enforcer(\"path/to/model.conf\", \"path/to/policy.csv\");\n\n    $enforcer-\u003esetWatcher($watcher);\n    \n    // Set callback, sets the callback function that the watcher will call,\n    // When the policy in DB has been changed by other instances.\n    // A classic callback is $enforcer-\u003eloadPolicy().\n    $watcher-\u003esetUpdateCallback(function () use ($enforcer) {\n        echo \"Now should reload all policies.\" . PHP_EOL;\n        $enforcer-\u003eloadPolicy();\n    });\n};\n\nWorker::runAll();\n\n```\n\n### Getting Help\n\n- [php-casbin](https://github.com/php-casbin/php-casbin)\n\n### License\n\nThis project is licensed under the [Apache 2.0 license](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-casbin%2Fworkerman-redis-watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-casbin%2Fworkerman-redis-watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-casbin%2Fworkerman-redis-watcher/lists"}