Looking to hire Laravel developers? Try LaraJobs

laravel-trello maintained by labrodev

Description
Stateless Trello REST API client for Laravel with the authorize-URL token flow.
Author
Last update
2026/07/19 13:59 (dev-main)
License
Downloads
0

Comments
comments powered by Disqus

Laravel Trello

Stateless Trello REST API client for Laravel with the authorize-URL token flow. You build an authorize URL, the user grants access on trello.com, Trello redirects back with a member token in the URL fragment, and every client call receives that token explicitly — the package stores nothing.

Installation

composer require labrodev/laravel-trello

Publish the config file:

php artisan vendor:publish --tag=trello-config

Set the environment variables:

TRELLO_API_KEY=your-power-up-api-key
TRELLO_APP_NAME="My App"
TRELLO_RETURN_URL=https://my-app.test/trello/callback

Authorize flow

Build the URL and redirect the user to it. The state value is appended to the return URL as a query parameter, so you can verify the round-trip:

use Labrodev\Trello\TrelloAuthorizeUrl;

$url = new TrelloAuthorizeUrl()->build(state: $state);

return redirect()->away($url);

Trello redirects back to TRELLO_RETURN_URL?state=... with the token in the URL fragment (#token=...). Capture it with a small piece of frontend code, then validate it before storing:

use Labrodev\Trello\TrelloClient;
use Labrodev\Trello\Exceptions\TrelloAuthFailed;

$trelloClient = new TrelloClient();

try {
    $trelloMember = $trelloClient->member(token: $token);
} catch (TrelloAuthFailed) {
    // token invalid — reject it
}

Client calls

Every method takes the member token first; the API key falls back to config('trello.key') unless passed as the last argument.

use Labrodev\Trello\TrelloClient;

$trelloClient = new TrelloClient();

$trelloMember = $trelloClient->member(token: $token);          // TrelloMember (id, username, fullName)
$trelloBoards = $trelloClient->boards(token: $token);          // list<TrelloBoard> (open boards)
$trelloLists = $trelloClient->lists(token: $token, boardId: $boardId); // list<TrelloList>

$cardId = $trelloClient->createCard(
    token: $token,
    listId: $listId,
    name: 'Card title',
    description: 'Card description',
);

$trelloClient->archiveCard(token: $token, cardId: $cardId);
$trelloClient->revokeToken(token: $token); // best-effort — safe to catch and ignore

Exceptions

  • Labrodev\Trello\Exceptions\TrelloAuthFailed — Trello returned 401/403, or no API key is available.
  • Labrodev\Trello\Exceptions\TrelloRequestFailed — any other failed request.

Both carry fixed messages only. Trello credentials travel in query strings, so no URL, token, key, or response body is ever interpolated into an exception message.

Testing

composer test      # pest
composer phpstan   # larastan, level 7
composer pint      # laravel preset
composer check     # all of the above

License

MIT. See LICENSE.md.