承接 carpehora/classifiablebehavior 相关项目开发

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

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

carpehora/classifiablebehavior

Composer 安装命令:

composer require carpehora/classifiablebehavior

包简介

ClassifiableBehavior is a propel behavior allowing to tag on a list of user defined scopes. kind of Ressource Access Control.

README 文档

README

Build Status

Quick start

Simply declare the behavior for the classifiable objects to allow filtering by classifications:

<database name="propel">
  <table name="repository">
    <column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" />
    <column name="name" type="VARCHAR" size="255" />
    <behavior name="classifiable" />
  </table>
</database>

then just add classificationements to your object:

<?php
// create your objects...
$MyPhpRepo = new Repository();
$MyPhpRepo->setName('my php repository');
$MyPhpRepo->classify('visibility', 'public');
$MyPhpRepo->classify('language', 'php');
$MyPhpRepo->classify('language', 'js');
$MyPhpRepo->classify('license', 'MIT');

$MyJsRepo = new Repository();
$MyJsRepo->setName('my php repository');
$MyJsRepo->classify('language', 'js');
$MyJsRepo->classify('language', 'php'); // is now classified in js AND php
$MyJsRepo->classify('license', 'GPL');
$MyJsRepo->disclose('language', 'js'); // now only classified in php


// ...and then retrieve it
RepositoryQuery::create()
  // filter for 'php' AND 'js' language, paranoid
  ->filterByClassified('language', array('php', 'js'), 'and', $paranoid = true)
  // filter for 'MIT'OR 'GPL' license, paranoid
  ->filterByClassified('license', array('MIT', 'BSD'), 'or', $paranoid = true)
  // filter for public visibility,
  // default is public, so request match if no visibility defined
  ->filterByClassified('visibility', 'public', null, $paranoid = false);

Previous example will return a PropelCollection with $MyPhpRepo in it.

OR searches are easily done by giving an array and the operator to use for subqueries:

<?php
RepositoryQuery::create()
  // filter by OR queries
  ->filterByClassified(array(
          'license' => array('MIT', 'BSD'), // licensed under MIT AND BSD as defined $operator argument
          'visibility' => 'public',         // or with public visibility
        ), $operator = 'AND', $paranoid = true)

To retrieve classifications an object is attached to, just call the getClassification method:

<?php
$myRepo->classify(array(
  'license' => array('MIT', 'BSD'),
  'visibility' => 'public'
), 'AND', $excludeUnclassified = true);
// return $myRepo

$myRepo->getClassification();
// array(
//  'license' => array('MIT', 'BSD'),
//  'visibility' => 'public'
// )

$myRepo->isClassified(array(
  'license' => array('MIT', 'BSD'),
  'visibility' => 'public'
), 'AND', $excludeUnclassified = true);
// return true

$myRepo->disclose();

To ease classifications management, behavior uses a unique classification table shared for all classified content. To use separate tables, just override the classification_table parameter.

Usage

You can use ClassifiableBehavior:

  • limit access to classified content
  • to organize collections and ease filtering
  • to tag objects
  • put your idea here

Installation

Under the hood

Behavior creates a cross reference table to access classification dictionnary and filters using EXISTS statements.

Advanced configuration

Following parameters are available :

  • classification_table: table to use to handle classifications.
  • classification_column: classification column to use.
  • scope_column: scope column to use.
  • auto_create_classification: if no classification found for parameters, should it be created ?
  • scope_default: comma separated default scope list.
  • scope_matching: how to match on scope ?
    • strict: namespace has to be strictly equal
    • nested: namespace has to start the same. separator is defined as nesting_separator
    • none: no namespace check
  • nesting_separator: separator to use on nested scopes

Scopes

A scope can be used to organize classifications. You can use namespaced scope by providing a nesting_separator. In such case, you can organize your classifications as files and folders and search can be done on all the scope descendants.

A scope can either be a foreign key to an object.

TODO

  • AR disclose method
  • nesting namespaces
  • Index classification table fields

carpehora/classifiablebehavior 适用场景与选型建议

carpehora/classifiablebehavior 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 6, 最近一次更新时间为 2012 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 carpehora/classifiablebehavior 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 26
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-03-16