albreis/trello

1.0.0 2021-06-14 18:39 UTC

This package is auto-updated.

Last update: 2024-09-15 01:36:22 UTC


README

A simple Object Oriented wrapper for the Trello API, written in PHP7.4.

使用Trello API v1. The object API is very similar to the RESTful API.

特性

  • 遵循PSR-0规范和编码标准:易于自动加载
  • 轻量快速,得益于API类的懒加载
  • 经过广泛测试
  • 已准备好支持Symfony 5

要求

安装

推荐使用composer

$ composer require albreis/trello

示例

use Trello\Client;

$client = new Client();
$client->authenticate('api_key', 'token', Client::AUTH_URL_CLIENT_ID);

$boards = $client->api('member')->boards()->all();

$client对象为您提供了访问整个Trello API的权限。

使用Trello管理器的进阶用法

此包包括API之上简单模型层,具有链式API,允许对Trello对象进行后续操作

use Trello\Client;
use Trello\Manager;

$client = new Client();
$client->authenticate('api_key', 'token', Client::AUTH_URL_CLIENT_ID);

$manager = new Manager($client);

$card = $manager->getCard('547440ad3f8b882bc11f0497');

$card
    ->setName('Test card')
    ->setDescription('Test description')
    ->save();

将Trello事件分发到您的应用

该服务使用Symfony EventDispatcher组件将事件分发到传入的webhook。

查看Events类常量以获取名称和相关事件类。

use Trello\Client;
use Trello\Service;
use Trello\Events;

$client = new Client();
$client->authenticate('api_key', 'token', Client::AUTH_URL_CLIENT_ID);

$service = new Service($client);

// Bind a callable to a given event...
$service->addListener(Events::BOARD_UPDATE, function ($event) {
    $board = $event->getBoard();

    // do something
});

// Check if the current request was made by a Trello webhook
// This will dispatch any Trello event to listeners defined above
$service->handleWebhook();

文档

贡献

请随时提出任何评论,提交问题或创建pull请求。

许可

albreis/trello遵循MIT许可 - 有关详细信息,请参阅LICENSE文件

致谢