Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: upgrade to PHP 8.0 and PHP-Casbin 4.0 #48

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [ 7.2, 7.3, 7.4, 8.0, 8.1, 8.2 ]
php: [ 8.0, 8.1, 8.2, 8.3 ]

name: PHP${{ matrix.php }}

Expand Down
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
],
"license": "Apache-2.0",
"require": {
"casbin/casbin": "~3.0",
"topthink/framework": "~6.0|^8.0.3",
"topthink/think-migration": "^3.1.0",
"casbin/psr3-bridge": "^1.1"
"php": ">=8.0",
"casbin/casbin": "~4.0",
"topthink/framework": "^8.0.3",
"topthink/think-migration": "^3.1.0"
},
"require-dev": {
"phpunit/phpunit": "~7.0|~8.0|~9.0",
"php-coveralls/php-coveralls": "^2.4",
"topthink/think": "~6.0|~8.0"
"phpunit/phpunit": "~9.0",
"php-coveralls/php-coveralls": "^2.7",
"topthink/think": "~8.0"
},
"autoload": {
"psr-4": {
Expand Down
21 changes: 10 additions & 11 deletions src/TauthzService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace tauthz;

use Casbin\Bridge\Logger\LoggerBridge;
use Casbin\Enforcer;
use Casbin\Model\Model;
use Casbin\Log\Log;
use Casbin\Log\Logger\DefaultLogger;
use think\Service;
use tauthz\command\Publish;

Expand Down Expand Up @@ -42,7 +42,15 @@ public function register()
$model->loadModel($config['model']['config_text']);
}

return new Enforcer($model, app($adapter), $this->app->config->get('tauthz.log.enabled', false));
if ($logger = $this->app->config->get('tauthz.log.logger')) {
if (is_string($logger)) {
$logger = new DefaultLogger($this->app->make($logger));
}

Log::setLogger($logger);
}

return new Enforcer($model, app($adapter), $logger, $this->app->config->get('tauthz.log.enabled', false));
});
}

Expand All @@ -55,15 +63,6 @@ public function boot()
{
$this->mergeConfigFrom(__DIR__.'/../config/tauthz.php', 'tauthz');

// 设置 Casbin Logger
if ($logger = $this->app->config->get('tauthz.log.logger')) {
if (is_string($logger)) {
$logger = $this->app->make($logger);
}

Log::setLogger(new LoggerBridge($logger));
}

$this->commands(['tauthz:publish' => Publish::class]);
}

Expand Down
Loading