{"id":14966498,"url":"https://github.com/php-casbin/yii-casbin","last_synced_at":"2025-10-25T16:30:56.587Z","repository":{"id":62499962,"uuid":"268704000","full_name":"php-casbin/yii-casbin","owner":"php-casbin","description":"Use casbin in Yii PHP Framework, Casbin is a powerful and efficient open-source access control library.","archived":true,"fork":false,"pushed_at":"2020-06-02T08:00:24.000Z","size":18,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-30T01:43:46.309Z","etag":null,"topics":["access-control","acl","casbin","permission","rbac","yii"],"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-06-02T04:52:13.000Z","updated_at":"2024-07-06T15:23:45.000Z","dependencies_parsed_at":"2022-11-02T11:47:11.431Z","dependency_job_id":null,"html_url":"https://github.com/php-casbin/yii-casbin","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Fyii-casbin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Fyii-casbin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Fyii-casbin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Fyii-casbin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-casbin","download_url":"https://codeload.github.com/php-casbin/yii-casbin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238174140,"owners_count":19428631,"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":["access-control","acl","casbin","permission","rbac","yii"],"created_at":"2024-09-24T13:36:29.041Z","updated_at":"2025-10-25T16:30:51.271Z","avatar_url":"https://github.com/php-casbin.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yii-Casbin\n\n[![Build Status](https://travis-ci.org/php-casbin/yii-casbin.svg?branch=master)](https://travis-ci.org/php-casbin/yii-casbin)\n[![Coverage Status](https://coveralls.io/repos/github/php-casbin/yii-casbin/badge.svg)](https://coveralls.io/github/php-casbin/yii-casbin)\n[![Latest Stable Version](https://poser.pugx.org/casbin/yii-adapter/v/stable)](https://packagist.org/packages/casbin/yii-adapter)\n[![Total Downloads](https://poser.pugx.org/casbin/yii-adapter/downloads)](https://packagist.org/packages/casbin/yii-adapter)\n[![License](https://poser.pugx.org/casbin/yii-adapter/license)](https://packagist.org/packages/casbin/yii-adapter)\n\n\u003e ## It is worth mentioning that we now recommend [Yii-Permission](https://github.com/php-casbin/yii-permission).\n\nUse [Casbin](https://github.com/php-casbin/php-casbin) in Yii 2.0 PHP Framework.\n\n## Installation\n\n### Getting Composer package\n\nRequire this package in the `composer.json` of your Yii 2.0 project. This will download the package.\n\n```\ncomposer require casbin/yii-adapter\n```\n\n### Configuring application\n\nTo use this extension, you have to configure the `Casbin` class in your application configuration:\n\n```php\nreturn [\n    //....\n    'components' =\u003e [\n        'casbin' =\u003e [\n            'class' =\u003e '\\CasbinAdapter\\Yii\\Casbin',\n            \n            /*\n             * Yii-casbin model setting.\n             */\n            'model' =\u003e [\n                // Available Settings: \"file\", \"text\"\n                'config_type' =\u003e 'file',\n                'config_file_path' =\u003e '/path/to/casbin-model.conf',\n                'config_text' =\u003e '',\n            ],\n\n            // Yii-casbin adapter .\n            'adapter' =\u003e '\\CasbinAdapter\\Yii\\Adapter',\n\n            /*\n             * Yii-casbin database setting.\n             */\n            'database' =\u003e [\n                // Database connection for following tables.\n                'connection' =\u003e '',\n                // CasbinRule tables and model.\n                'casbin_rules_table' =\u003e '{{%casbin_rule}}',\n            ],\n        ],\n    ]\n];\n```\n\n\n## Usage\n\nThis provides the basic access to Casbin via the `casbin` application component:\n\n```php\n\n$casbin = \\Yii::$app-\u003ecasbin;\n\n$sub = 'alice'; // the user that wants to access a resource.\n$obj = 'data1'; // the resource that is going to be accessed.\n$act = 'read'; // the operation that the user performs on the resource.\n\nif (true === $casbin-\u003eenforce($sub, $obj, $act)) {\n    // permit alice to read data1\n} else {\n    // deny the request, show an error\n}\n\n```\n\n## Define your own model.conf\n\n[Supported models](https://github.com/php-casbin/php-casbin#supported-models).\n\n## Learning Casbin\n\nYou can find the full documentation of Casbin [on the website](https://casbin.org/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-casbin%2Fyii-casbin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-casbin%2Fyii-casbin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-casbin%2Fyii-casbin/lists"}