zolli/phabricator-php-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

zolli/phabricator-php-api

最新稳定版本:2.0.2

Composer 安装命令:

composer require zolli/phabricator-php-api

包简介

PHP implementation for Phabricator conduit application

README 文档

README

---

Build Status Build Stability Code Coverage Scrutinizer Code Quality Test Results CRAP Report Dependency Status PHP7 Status

Phabricator PHP API (Conduit client)

This is a PHP based client for Phabricator API. Phabricator is an open source, software engineering platform, built in PHP, and it has a very nice API called Conduit. For all available endpoint and method name, see the Conduit Application in the live Phabricator instance.

Basic useful feature list:

  • Fully implemented all current API endpoint
  • Ability to make custom Client implementation
  • Custom handler class for each endpoint

Installation

With composer

Run this command inside your project

composer require zolli/phabricator-php-api

Or past this dependency into your composer.json manually

{
  "require": {
        "zolli/phabricator-php-api": "2.0.*"
    }
}

Documentation

Initialization

//Initialization the instance
$api = new \Phabricator\Phabricator('http://phabricator.example.com', 'cli-exmapletoken')

The API is now ready to use. This class uses magic method to proxy the calls to the suitable endpoint handler. Phabricator methods should looks like this: project.query. In this package exploded into two parts.

The first is the endpoint (Project in this example) and the method (query);

With this example the call is looks like this:

$result = $api->Project('query', ['status' => 'status-open']);

In this example the /api/project.query API is called and the status argument is passed.

Using custom client

This API of this package is allows you to make custom API clients that run the request for you. All client should implement the Phabricator\Client\ClientInterface interface.

Custom clients should be injected in two different way.

Injecting trough the constructor

$myClient = \Vendor\Package\MyAwesomeApiClient();

$api = new \Phabricator\Phabricator('http://phabricator.example.com', 'cli-exmapletoken', $myClient);

Or you can use the Phabricator::setClient(ClientInterface $client) method.

$myClient = \Vendor\Package\MyAwesomeApiClient();

$api = new \Phabricator\Phabricator('http://phabricator.example.com', 'cli-exmapletoken');
$api->setClient($myClient);

Custom endpoint handlers

Handlers are various classes that handle the execution and post-processing of endpoint methods. By default all API endpoint have handler, but only the default that no do any pre- or post-processing.

By example a custom handler can read and write files when using the file.upload or file.download method.

To achieve this create a class that implements the \Phabricator\Endpoints\EndpointInterface and extends the \Phabricator\Endpoints\BaseEndpoint class and you good to go.

The BaseEndpoint provides a defaultExecutor() method that executed when an endpoint method not has any specific executor.

When creating custom executor method this methods will be used when calling an endpoint method.

Look the BaseEndpoint and any endpoint handler for more information.

Suppose that you created and endpoint handler with this FQCN: \Vendor\Package\Hander\FileHander; You can push this handler like this:

Tha first argument is the endpoint name for this handler is listen and the second is the FQCN of the handler.

    $api = new \Phabricator\Phabricator('http://phabricator.example.com', 'cli-exmapletoken');

    $api->pushEndpointHandler('File', FileHandler::class);

Responses

The client is returning \Phabricator\Response\ConduitResponse as response. Look API documentation for methods.

Upgrading

From 1.0.0

In the 2.0.0 release the API is changed significantly and the underlying API dramatically. So, this release probably not compatible with components that created for 1.0.0

Main API Differences:

  • The \Phabricator\Phabricator constructor only take the baseUrl and the tokens as arguemnt
  • Client registration in constructor is now optional
  • Registering custom endpoint handler only require the handler Fully qualified class name, not instance
  • Instead of \stdClass responses now \Phabricator\Response\ConduitResponse objects.
  • The \Phabricator\Client\ClientInterface interface changed significantly.
  • The arguments of endpoint handler methods (executors) changed.
  • Now not using exceptions from global namespace, instead use buildr/foundation package exceptions
  • Clients not responsible for request data formatting.

API Documentation

The 2.0.0 release API documentation is available here: API Documentation

Contribution

Project link

For contribution guide and coding standard please visit our Coding Standard Repository

Licensing

This project licensed under GNU - General Public License, version 3

GPLv3 Logo

zolli/phabricator-php-api 适用场景与选型建议

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

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

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

围绕 zolli/phabricator-php-api 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 34.82k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 20
  • Watchers: 4
  • Forks: 4
  • 开发语言: PHP

其他信息

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