定制 quickhelper/quicktrello 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

quickhelper/quicktrello

Composer 安装命令:

composer require quickhelper/quicktrello

包简介

A Laravel package for quick integration with Trello API

README 文档

README

A Laravel package for quick and easy integration with the Trello API, providing a comprehensive set of features for managing boards, lists, cards, members, and more.

Installation

You can install the package via composer:

composer require quickhelper/quicktrello

Publishing the config file

php artisan vendor:publish --tag="quicktrello-config"

This will publish the config file to config/quicktrello.php.

Configuration

Add the following to your .env file:

TRELLO_API_KEY=your_trello_api_key
TRELLO_TOKEN=your_trello_token
TRELLO_WEBHOOK_SECRET=optional_webhook_secret

You can get your API key and token from https://trello.com/app-key.

Usage

Boards

use QuickTrello\Facades\QuickTrello;

// Get all boards
$boards = QuickTrello::getBoards();

// Get a specific board
$board = QuickTrello::getBoard('board_id');

// Get board members
$members = QuickTrello::getBoardMembers('board_id');

Lists

// Get lists for a board
$lists = QuickTrello::getLists('board_id');

// Create a new list
$list = QuickTrello::createList('board_id', 'List Name', [
    'pos' => 'top' // Optional position ('top', 'bottom', or a position value)
]);

// Update a list
$list = QuickTrello::updateList('list_id', [
    'name' => 'New List Name',
    'pos' => 'bottom'
]);

// Archive a list
$list = QuickTrello::archiveList('list_id', true); // Archive
$list = QuickTrello::archiveList('list_id', false); // Unarchive

Cards

// Get cards for a list
$cards = QuickTrello::getCards('list_id');

// Create a card
$card = QuickTrello::createCard('list_id', 'Card title', [
    'desc' => 'Card description',
    'due' => '2025-03-01',
    'pos' => 'top'
]);

// Update a card
$card = QuickTrello::updateCard('card_id', [
    'name' => 'Updated Card Title',
    'desc' => 'Updated description'
]);

// Move a card to another list
$card = QuickTrello::moveCard('card_id', 'new_list_id');

// Add a comment to a card
$comment = QuickTrello::addComment('card_id', 'This is a comment');

// Add a label to a card
$label = QuickTrello::addLabel('card_id', 'label_id');

// Remove a label from a card
$result = QuickTrello::removeLabel('card_id', 'label_id');

// Add a due date to a card
$card = QuickTrello::addDueDate('card_id', '2025-03-01T12:00:00Z');

Members and Assignments

// Get all board members
$members = QuickTrello::getBoardMembers('board_id');

// Get all organization members
$members = QuickTrello::getOrganizationMembers('org_id');

// Assign a member to a card
$result = QuickTrello::assignMemberToCard('card_id', 'member_id');

// Remove a member from a card
$result = QuickTrello::removeMemberFromCard('card_id', 'member_id');

// Get members assigned to a card
$members = QuickTrello::getCardMembers('card_id');

Checklists

// Add a checklist to a card
$checklist = QuickTrello::addChecklist('card_id', 'Checklist Name');

// Add an item to a checklist
$item = QuickTrello::addChecklistItem('checklist_id', 'Checklist Item');

Webhooks

The package automatically registers a webhook endpoint at /api/trello/webhooks (configurable). You can create webhooks in Trello to receive notifications when events occur:

// Create a webhook
$webhook = QuickTrello::createWebhook(
    'https://your-app.com/api/trello/webhooks',
    'model_id', // board_id, card_id, etc.
    'Description of webhook'
);

// Get all webhooks
$webhooks = QuickTrello::getWebhooks();

// Delete a webhook
$result = QuickTrello::deleteWebhook('webhook_id');

Listening for Webhook Events

You can listen for webhook events in your Laravel application:

// In your EventServiceProvider
Event::listen('quicktrello.webhook_received', function ($payload) {
    // Handle all webhook events
});

// Listen for specific event types
Event::listen('quicktrello.createCard', function ($payload) {
    // Handle card creation events
});

Event::listen('quicktrello.updateCard', function ($payload) {
    // Handle card update events
});

Event::listen('quicktrello.addMemberToCard', function ($payload) {
    // Handle when a member is assigned to a card
});

Event::listen('quicktrello.createList', function ($payload) {
    // Handle list creation events
});

Advanced Usage

Error Handling

The package throws TrelloException when API errors occur. You can catch these exceptions to handle errors gracefully:

use QuickTrello\Exceptions\TrelloException;

try {
    $card = QuickTrello::createCard('list_id', 'Card title');
} catch (TrelloException $e) {
    // Handle error
    $statusCode = $e->getCode();
    $message = $e->getMessage();
}

Webhook Verification

For added security, you can set a webhook secret in your config and the package will verify incoming webhook requests:

// In config/quicktrello.php
'webhook_secret' => env('TRELLO_WEBHOOK_SECRET'),

Available Methods

Boards

  • getBoards()
  • getBoard(string $boardId)
  • getBoardMembers(string $boardId)

Lists

  • getLists(string $boardId)
  • createList(string $boardId, string $name, array $options = [])
  • updateList(string $listId, array $data)
  • archiveList(string $listId, bool $archived = true)

Cards

  • getCards(string $listId)
  • createCard(string $listId, string $name, array $options = [])
  • updateCard(string $cardId, array $data)
  • moveCard(string $cardId, string $listId)
  • addComment(string $cardId, string $text)
  • addLabel(string $cardId, string $labelId)
  • removeLabel(string $cardId, string $labelId)
  • addDueDate(string $cardId, string $dueDate)

Members

  • getBoardMembers(string $boardId)
  • getOrganizationMembers(string $orgId)
  • assignMemberToCard(string $cardId, string $memberId)
  • removeMemberFromCard(string $cardId, string $memberId)
  • getCardMembers(string $cardId)

Checklists

  • addChecklist(string $cardId, string $name)
  • addChecklistItem(string $checklistId, string $name)

Webhooks

  • createWebhook(string $callbackUrl, string $idModel, string $description = '')
  • deleteWebhook(string $webhookId)
  • getWebhooks()

License

The MIT License (MIT). Please see License File for more information.

Best regards,
Yossef Ashraf

quickhelper/quicktrello 适用场景与选型建议

quickhelper/quicktrello 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.76k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-27