承接 anroots/db-acl 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

anroots/db-acl

最新稳定版本:1.0.1

Composer 安装命令:

composer require anroots/db-acl

包简介

Database-based ACL module for Kohana 3.3.

README 文档

README

Database-based ACL module for Kohana 3.3 / PHP 5.4. Users get authorization to perform certain actions through their roles. Each role can have several permissions. You define new roles and permissions in the database as you see fit.

I actually do recommend against using this module unless you specifically want the role/permission management to happen in the database (some projects need permissions managed from the GUI, by administrative users). For an alternative (and much better) implementation, see https://github.com/vendo/acl.

Dependencies

  1. PHP >= 5.4
  2. Kohana >= 3.3
  3. Default Database, Auth and ORM modules

Usage

// ...
public function save_customer() {
	$current_user = Auth::instance()->get_user();

	if (!$current_user->can(Permission::EDIT_CUSTOMERS)) {
		throw new Authorization_Exception();
	}

	// Save the Customer ORM model
	$this->save();
}
// ...

Defining permissions

Create new entries in the permissions table as you develop your application. Associate permissions with roles and check for the user's authorization to perform some action in your code.

Permission constants

Override Permission in your APPPATH to define permission constants. Constant values correspond to the id column of the permissions table.

<?php
class Model_Permission extends ACL_Model_Permission {
	const EDIT_USERS = 1;
	const ADD_NEW_POST = 2;
}

$user->can(Model_Permission::EDIT_USERS);

Checking permissions

  • $user->can($permission); // Has the permission
  • $user->has_permissions(array $permissions); // Has all of the specified permissions
  • $user->has_any_permission(array $permission); // Has any of the specified permissions

Installation

  • Add the files to your modules folder

As a Git submodule:

git clone git://github.com/anroots/kohana-db-acl.git modules/db-acl

As a Composer dependency

{
	"require": {
		"php": ">=5.4.0",
		"composer/installers": "*",
		"anroots/db-acl":"1.*"
	}
}
  • Enable in bootstrap.php (above/before auth/orm modules)
  • Run create-tables.sql (and orm/auth-schema-*.sql if you haven't already done so)
  • Make sure that your Model_User (if overwritten) uses the trait ACL_Trait_User
  • Create some permissions and start calling one of the permission methods on Model_User

anroots/db-acl 适用场景与选型建议

anroots/db-acl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.09k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2012 年 11 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「acl」 「kohana」 「kohana module」 「roles」 「permissions」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 anroots/db-acl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 anroots/db-acl 我们能提供哪些服务?
定制开发 / 二次开发

基于 anroots/db-acl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.09k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 30
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 6
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-11-14