Php Trello API

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

View the Project on GitHub cdaguerre/php-trello-api

Features

Installation

The recommended way is using composer:

$ composer require cdaguerre/php-trello-api:@dev

However, php-trello-api follows the PSR-0 naming conventions, which means you can easily integrate php-trello-api class loading in your own autoloader.


Basic usage

use Trello\Client;

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

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

The $client object gives you access to the entire Trello API.


Advanced usage with the Trello manager

This package includes a simple model layer above the API with a nice chainable API allowing following manipulation of Trello objects:

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();

Dispatching Trello events to your app

The service uses the Symfony EventDispatcher component to dispatch events occuring on incoming webhooks.

Take a look at the Events class constants for names and associated event classes.

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();

Documentation