Install via Composer (recommended):
composer require taiga/php-sdk:^1.0
curl/openssl enabled).Basic Initialization:
use Taiga\Taiga;
$taiga = new Taiga\Taiga('https://your-taiga-instance.com/api/v1/', 'your-api-token');
First Use Case: Fetching Projects
$projects = $taiga->projects->getAll();
// Returns array of projects
Taiga\ (e.g., Taiga\Projects, Taiga\Issues).CRUD Operations:
// Create an issue
$issue = $taiga->issues->create([
'subject' => 'Fix bug',
'description' => '...',
'project' => 1,
]);
// Update an issue
$taiga->issues->update($issue->id, ['status' => 'closed']);
// Delete an issue
$taiga->issues->delete($issue->id);
Pagination Handling:
$issues = $taiga->issues->getAll(['page' => 1, 'per_page' => 20]);
// Loop through results (SDK returns paginated arrays)
Query Parameters:
// Filter issues by project and status
$issues = $taiga->issues->getAll([
'project' => 1,
'status' => 'open',
'order_by' => '-created_at',
]);
Webhooks (if supported):
Laravel Service Provider: Bind the SDK as a singleton for dependency injection:
$this->app->singleton('taiga', function ($app) {
return new Taiga\Taiga(config('taiga.api_url'), config('taiga.api_token'));
});
API Rate Limiting:
Implement retry logic for 429 Too Many Requests (e.g., using Guzzle middleware).
Testing:
Mock the SDK’s HTTP client (e.g., Mockery) to test business logic without hitting Taiga’s API.
Deprecated API:
No PSR-7/HTTP Client Abstraction:
curl directly. For modern Laravel apps, wrap it in a Guzzle client for consistency:
$client = new \GuzzleHttp\Client();
$taiga = new Taiga\Taiga($client, 'https://api-url', 'token');
Error Handling:
HttpException or custom exceptions:
try {
$taiga->issues->get($id);
} catch (\Taiga\Exception $e) {
throw new \App\Exceptions\TaigaException($e->getMessage(), $e->getCode());
}
Token Management:
.env:
TAIGA_API_TOKEN=your_token_here
$taiga = new Taiga\Taiga(config('taiga.api_url'), config('taiga.api_token'));
Enable Verbose Logging:
$taiga->setDebug(true); // Logs raw API requests/responses
Check Response Codes:
404 for missing resources. Validate IDs before operations:
try {
$taiga->issues->get($id);
} catch (\Taiga\Exception $e) {
if ($e->getCode() === 404) {
// Handle missing issue
}
}
Custom Endpoints:
Taiga\Taiga:
class ExtendedTaiga extends Taiga\Taiga {
public function customEndpoint($data) {
return $this->request('POST', '/custom', $data);
}
}
Middleware:
request method.Event Dispatching:
issue.created):
$issue = $taiga->issues->create($data);
event(new \App\Events\IssueCreated($issue));
How can I help you explore Laravel packages today?