Skip to content

Commit

Permalink
BREAKING CHANGE: change namespace to Cake\Permission and support cake…
Browse files Browse the repository at this point in the history
…php 5.0
  • Loading branch information
leeqvip committed Sep 11, 2023
1 parent 92a84f3 commit c45419a
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 4,177 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build.yml → .github/workflows/test.yml
@@ -1,4 +1,4 @@
name: build
name: test

on:
push:
Expand All @@ -15,22 +15,22 @@ jobs:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: cake_adapter
MYSQL_DATABASE: cake-permission
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
fail-fast: true
matrix:
php: [ 7.3, 7.4 ]
stability: [ prefer-lowest, prefer-stable ]
php: [7.3, 7.4, 8.0, 8.1, 8.2]
stability: [prefer-stable]

name: PHP ${{ matrix.php }} - ${{ matrix.stability }}

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -73,10 +73,10 @@ jobs:
runs-on: ubuntu-latest
needs: [ test, upload-coverage ]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '14.17'
node-version: 'lts/*'

- name: Run semantic-release
env:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -7,4 +7,6 @@ composer.lock
*.iml

# coverage report
/build
/build

.phpunit.result.cache
16 changes: 9 additions & 7 deletions README.md
@@ -1,8 +1,10 @@
# Cake-Casbin
# Cake-Permission

[![Latest Stable Version](https://poser.pugx.org/casbin/cake-adapter/v/stable)](https://packagist.org/packages/casbin/cake-adapter)
[![Total Downloads](https://poser.pugx.org/casbin/cake-adapter/downloads)](https://packagist.org/packages/casbin/cake-adapter)
[![License](https://poser.pugx.org/casbin/cake-adapter/license)](https://packagist.org/packages/casbin/cake-adapter)
[![Test](https://github.com/php-casbin/cake-permission/workflows/build/badge.svg?branch=master)](https://github.com/php-casbin/cake-permission/actions)
[![Coverage Status](https://coveralls.io/repos/github/php-casbin/cake-permission/badge.svg)](https://coveralls.io/github/php-casbin/cake-permission)
[![Latest Stable Version](https://poser.pugx.org/casbin/cake-adapter/v/stable)](https://packagist.org/packages/casbin/cake-permission)
[![Total Downloads](https://poser.pugx.org/casbin/cake-adapter/downloads)](https://packagist.org/packages/casbin/cake-permission)
[![License](https://poser.pugx.org/casbin/cake-adapter/license)](https://packagist.org/packages/casbin/cake-permission)

Use Casbin in CakePHP Framework, Casbin is a powerful and efficient open-source access control library.

Expand All @@ -11,7 +13,7 @@ Use Casbin in CakePHP Framework, Casbin is a powerful and efficient open-source
Require this package in the `composer.json` of your CakePHP project. This will download the package.

```
composer require casbin/cake-adapter
composer require casbin/cake-permission
```

create config file `config/casbin.php` for Casbin:
Expand All @@ -32,7 +34,7 @@ return [
],

// Cake-casbin adapter .
'adapter' => '\CasbinAdapter\Cake\Adapter',
'adapter' => '\Cake\Permission\Adapter',

/*
* Cake-casbin database setting.
Expand Down Expand Up @@ -72,7 +74,7 @@ $sub = 'alice'; // the user that wants to access a resource.
$obj = 'data1'; // the resource that is going to be accessed.
$act = 'read'; // the operation that the user performs on the resource.

$casbin = new \CasbinAdapter\Cake\Casbin();
$casbin = new \Cake\Permission\Casbin();

if (true === $casbin->enforce($sub, $obj, $act)) {
// permit alice to read data1
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Expand Up @@ -4,22 +4,22 @@
"description": "Use casbin in CakePHP. ",
"authors": [
{
"name": "TechLee",
"email": "techlee@qq.com"
"name": "JonLee",
"email": "leeqvip@gmail.com"
}
],
"license": "Apache-2.0",
"require": {
"php": ">=7.2.0",
"cakephp/cakephp": "~4.0",
"cakephp/cakephp": "~4.0|~5.0",
"casbin/casbin": "~3.1"
},
"require-dev": {
"phpunit/phpunit": "~8.5.0 || ^9.3"
},
"autoload": {
"psr-4": {
"CasbinAdapter\\Cake\\": "src/"
"Cake\\Permission\\": "src/"
}
}
}

0 comments on commit c45419a

Please sign in to comment.