承接 kingsquare/communibase-connector-php 相关项目开发

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

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

kingsquare/communibase-connector-php

Composer 安装命令:

composer require kingsquare/communibase-connector-php

包简介

This is the Communibase connector for PHP.

README 文档

README

Communibase

Scrutinizer Quality Score Travis CI Latest Stable Version License

A general-purpose Communibase client for PHP projects, compatible with composer packaging-projects.

A connector may be constructed to do REST-calls on the Communibase API.

The behaviour of this package should always Mimic the node-version

Usage

The easiest way to install the connector is to use Composer:

composer require kingsquare/communibase-connector-php

Now you should be able to install the package by updating your composer environment composer install
The connector is available and usable as follows:

require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload
use Communibase\Connector;

$cb = new Connector('<your api key here>');
$peopleNamedTim = $cb->search('Person', ['firstName' => 'Tim'], ['limit' => 5]);
print_r($peopleNamedTim);

API

"entityType" should be the Communibase Entitytype, e.g. "Person", "Invoice", etc. To see all the entity types your API key allows, see the API docs and insert your API key there.

"selectors" may be provided MongoDb style as array-definitions.

"params" is a key value store for e.g. fields, limit, page and/or sort . See API docs for more details. In addition to the nodeJS version of this parameter, the fields value may also be an array of fields. This will work more intuitively in PHP environments.

$cbc->search($entityType, $selector, $params): entity[];

$cbc->getAll($entityType, $params): entity[];

$cbc->getById($entityType, $id, $params, $version): entity;

$cbc->getByIds($entityType, $ids, $params): entity[];

$cbc->getId($entityType, $selector): string;

$cbc->getIds($entityType, $selector, $params): null|string[];

$cbc->getByRef($ref[, $parent]): entity

$cbc->getTemplate($entityType): array;

$cbc->getHistory($entityType, $id): array;

$cbc->update($entityType, $properties): responseData;

$cbc->destroy($entityType, $id): responseData;

$cbc->generateId(): string - Generate a new, fresh Communibase ID

//Use for Files only to get a string with the binary contents
$cbc->getBinary(id): string;

Whenever a function like getByIds() or getByIds() returns null, the property cbc->lastError should be available containing an error message

Entity

An entity is an associative array containing a key/value store of data in Communibase.

E.g.

[
  'firstName' => 'Tim',
  'addresses' => [
    [
      'street' => 'Breestraat',
      // ...
    ], 
    // ...
  ]
]

Error handling

The connector may throw an error when something goes wrong. Default error handling is as follows:

try {
  $person = $cbc->getById('Person', '_PERSON_ID_');
} catch (\Communibase\Exception $e) {
  echo $e->getMessage();
}

A special type of error handling involves "Validity" errors for posted documents.

try {
  $person = $cbc->update('Person', [...]);
} catch (\Communibase\Exception $e) {
  //get an array of errors, per property:
  //  [
  //    [
  //      'field' => '<string>',
  //      'message' => '<string>'
  //    ]
  //  ]
  print_r($e->getErrors());
}

Query Logging

It is also possible to add a query logger to the connector.

Stack query data for debug/dev purposes:

$connector->setQueryLogger(new DebugStack());

Query data available after run via $connector->getQueryLogger()->queries

Echo query for debug/dev purposes (handy for cli):

$connector->setQueryLogger(new EchoQueryLogger());

Echoes each query to the current output stream.

Create own query logging:

$connector->setQueryLogger(new MyOwnQueryLogger());

MyOwnQueryLogger implements QueryLogger and does something with the data.. possible db/api call

Contributions / Bugreports

If you're using this app and have questions and/or feedback, please file an issue on Github.
Also we welcome new features and code, so please don't hesitate to get that pull request online!

kingsquare/communibase-connector-php 适用场景与选型建议

kingsquare/communibase-connector-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.1k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2014 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 kingsquare/communibase-connector-php 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 5.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-02-26