memcrab/access
Composer 安装命令:
composer require memcrab/access
包简介
PHP Access lib for memCrab Core API
README 文档
README
Status
It's lightweight php access rights module.
Features
- Support services, actions and roles that need to be controlled by access rights
- Support access groups that combaine multiple services and actions for access all of them to some role
- All configurations is array based and it may be simple YAML file
- Allows you to check role access to any Service/Action
- Allows to check role access to group of actions
- Allows you to get all groups that available for current role
- Allows to use rights matrix by roles or by services or by access groups it's allows you to check any rights by simple isset() using only keys of array.
- Used High performance yaml parse throw using updated pecl yaml-ext 2.0.0 for php 7.0
- Strict standart coding with full Typing of params and returns (by php 7.1)
- PSR-4 autoloading compliant structure
- Unit-Testing with PHPUnit
- Easy to use to any framework
Install
composer require memcrab/access
Dependencies
php extension YAML:
- for Ubuntu/Debian
- apt-get update
- apt-get install php-pear
- apt-get install php-dev
- apt-get install php-xml php7.0-xml
- apt-get install libyaml-dev
- pecl channel-update pecl.php.net
- pecl install yaml-2.0.0
- for OS X
- brew install php71 --with-pear
- brew install autoconf
- touch $(brew --prefix php71)/lib/php/.lock && chmod 0644 $(brew --prefix php71)/lib/php/.lock
- pecl install yaml-2.0.0
Usage
- init Access:
new memCrab\Access() - load rules:
->loadRules(array $rules)- $rules - Rules from yaml file for exaple
- run checks:
->checkRights(string $service, string $action, string $userRole)- $service - name of service (or maybe controller)
- $action - name of action
- $userRole - name of user role
Yaml Config Example
contentView: roles: [guest, user, admin] services: post: [get] product: [get] index: [get] catalog: [filter] contentManage: roles: [admin] services: post: [add, save, delete] product: [add, save, delete]
Run Example
require_once __DIR__ . "/../vendor/autoload.php"; use memCrab\Exceptions\FileException; use memCrab\File\Yaml; use memCrab\Access\Access; use memCrab\Exception\AccessException; try { $Yaml = new Yaml(); $rules = $Yaml->load("config/rules.yaml", null)->getContent(); $Access = new Access(); $Access->loadRules($rules); if(!$Access->checkRights("post", "save", "admin")) throw AccessException("Access Denie.", 401); // do all your work } catch(AccessException $error){ $Response = new \YourResponseClass(); $Response->setErrorResponse($error); } $Response->sendHeaders(); $Response->sendContent();
MIT Licensed
memcrab/access 适用场景与选型建议
memcrab/access 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 52.22k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 02 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「access」 「lib」 「memcrab」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 memcrab/access 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 memcrab/access 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 memcrab/access 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Provide a way to secure accesses to all routes of an symfony application.
A flexible FTP, SSL-FTP, and SSH-based SFTP client for PHP. This lib provides helpers that are easy to use to manage the remote files.
Client Legacy lib for Rest PKI
Biblioteca para geração de NFSE de Belo Horizonte
General Interface for access control
统计信息
- 总下载量: 52.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-02-16