{"id":20876065,"url":"https://github.com/php-casbin/phalcon-permission","last_synced_at":"2026-04-24T17:06:07.179Z","repository":{"id":41099973,"uuid":"283381973","full_name":"php-casbin/phalcon-permission","owner":"php-casbin","description":"An authorization library that supports access control models like ACL, RBAC, ABAC in Phalcon.","archived":false,"fork":false,"pushed_at":"2020-09-18T02:16:45.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-12T16:19:23.155Z","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":"2020-07-29T02:51:39.000Z","updated_at":"2023-10-07T14:12:23.000Z","dependencies_parsed_at":"2022-09-09T02:33:16.398Z","dependency_job_id":null,"html_url":"https://github.com/php-casbin/phalcon-permission","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/php-casbin/phalcon-permission","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Fphalcon-permission","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Fphalcon-permission/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Fphalcon-permission/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Fphalcon-permission/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-casbin","download_url":"https://codeload.github.com/php-casbin/phalcon-permission/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Fphalcon-permission/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32232711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"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":[],"created_at":"2024-11-18T06:49:55.631Z","updated_at":"2026-04-24T17:06:07.153Z","avatar_url":"https://github.com/php-casbin.png","language":"PHP","readme":"\u003ch1 align=\"center\"\u003ephalcon-permission\u003c/h1\u003e\n\u003cp align=\"center\"\u003eAn authorization library that supports access control models like ACL, RBAC, ABAC in Phalcon.\u003c/p\u003e\n\n## Installing\n\nRequire this package in the `composer.json` of your phalcon project. This will download the package.\n\n```shell\n$ composer require\n```\n\nConfigure database connection:\n```php\n'database' =\u003e [\n    'adapter' =\u003e 'mysql',\n    'host' =\u003e '127.0.0.1',\n    'username' =\u003e 'root',\n    'password' =\u003e '',\n    'dbname' =\u003e 'db-name',\n    'charset' =\u003e 'utf8',\n],\n```\n\nThen phalcon-permission migrations must run to create the needed tables. For this, you need to have installed the [Phalcon Dev Tools](https://github.com/phalcon/phalcon-devtools).\n\nuse [Phalcon Dev Tools](https://github.com/phalcon/phalcon-devtools) to migrate the migrations, run the command:\n\n```shell\n$ phalcon migration run --migrations=vendor/casbin/phalcon-permission/migrations\n```\n\nThis will create a new table named `casbin_rules`.\n\n## Usage\n\n### Quick start\n\n```php\nuse Easyswolle\\Permission\\Casbin;\nuse Easyswolle\\Permission\\Config;\n\n$config = new Config();\n$casbin = new Casbin($config);\n\n// adds permissions to a user\n$casbin-\u003eaddPermissionForUser('eve', 'articles', 'read');\n// adds a role for a user.\n$casbin-\u003eaddRoleForUser('eve', 'writer');\n// adds permissions to a rule\n$casbin-\u003eaddPolicy('writer', 'articles', 'edit');\n```\n\nYou can check if a user has a permission like this:\n\n```php\n// to check if a user has permission\nif ($casbin-\u003eenforce('eve', 'articles', 'edit')) {\n  // permit eve to edit articles\n} else {\n  // deny the request, show an error\n}\n```\n\n### Using Enforcer Api\n\nIt provides a very rich api to facilitate various operations on the Policy:\n\nGets all roles:\n\n```php\n$casbin-\u003egetAllRoles(); // ['writer', 'reader']\n```\n\nGets all the authorization rules in the policy.:\n\n```php\n$casbin-\u003egetPolicy();\n```\n\nGets the roles that a user has.\n\n```php\n$casbin-\u003egetRolesForUser('eve'); // ['writer']\n```\n\nGets the users that has a role.\n\n```php\n$casbin-\u003egetUsersForRole('writer'); // ['eve']\n```\n\nDetermines whether a user has a role.\n\n```php\n$casbin-\u003ehasRoleForUser('eve', 'writer'); // true or false\n```\n\nAdds a role for a user.\n\n```php\n$casbin-\u003eaddRoleForUser('eve', 'writer');\n```\n\nAdds a permission for a user or role.\n\n```php\n// to user\n$casbin-\u003eaddPermissionForUser('eve', 'articles', 'read');\n// to role\n$casbin-\u003eaddPermissionForUser('writer', 'articles','edit');\n```\n\nDeletes a role for a user.\n\n```php\n$casbin-\u003edeleteRoleForUser('eve', 'writer');\n```\n\nDeletes all roles for a user.\n\n```php\n$casbin-\u003edeleteRolesForUser('eve');\n```\n\nDeletes a role.\n\n```php\n$casbin-\u003edeleteRole('writer');\n```\n\nDeletes a permission.\n\n```php\n$casbin-\u003edeletePermission('articles', 'read'); // returns false if the permission does not exist (aka not affected).\n```\n\nDeletes a permission for a user or role.\n\n```php\n$casbin-\u003edeletePermissionForUser('eve', 'articles', 'read');\n```\n\nDeletes permissions for a user or role.\n\n```php\n// to user\n$casbin-\u003edeletePermissionsForUser('eve');\n// to role\n$casbin-\u003edeletePermissionsForUser('writer');\n```\n\nGets permissions for a user or role.\n\n```php\n$casbin-\u003egetPermissionsForUser('eve'); // return array\n```\n\nDetermines whether a user has a permission.\n\n```php\n$casbin-\u003ehasPermissionForUser('eve', 'articles', 'read');  // true or false\n```\n\nSee [Casbin API](https://casbin.org/docs/en/management-api) for more APIs.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-casbin%2Fphalcon-permission","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-casbin%2Fphalcon-permission","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-casbin%2Fphalcon-permission/lists"}