comindware/tracker-symfony-bundle
Install the Bundle
composer require comindware/tracker-symfony-bundle
Enable the bundle in config/bundles.php:
Comindware\TrackerBundle\ComindwareTrackerBundle::class => ['all' => true],
Configure the Bundle
Add your Comindware Tracker credentials to config/packages/comindware_tracker.yaml:
comindware_tracker:
api_url: 'https://your-tracker-instance.com/api'
api_key: '%env(COMINDWARE_TRACKER_API_KEY)%'
default_project_id: 123
First Use Case: Logging a Task
Inject the TrackerClient service and log a task:
use Comindware\TrackerBundle\Client\TrackerClientInterface;
class MyController
{
public function __construct(private TrackerClientInterface $trackerClient) {}
public function logTask()
{
$task = $this->trackerClient->createTask(
projectId: 123,
title: 'Fix login bug',
description: 'Users report issues with authentication.'
);
// Handle response (e.g., redirect or return JSON)
}
}
Key Documentation
src/Resources/doc/index.en.mdsrc/Resources/doc/index.ru.mdTask Management
$this->trackerClient->createTask($projectId, $title, $description, $priority);
$this->trackerClient->updateTask($taskId, ['status' => 'In Progress']);
$tasks = $this->trackerClient->getTasks($projectId, ['limit' => 10]);
Integration with Symfony Events Use the bundle’s events to trigger actions (e.g., log tasks on form submission):
// config/services.yaml
services:
App\EventListener\TaskLogger:
tags:
- { name: kernel.event_listener, event: app.form_submitted, method: logTask }
Dependency Injection Prefer dependency injection over direct instantiation. The bundle provides:
TrackerClientInterface (primary client)TrackerTaskManager (task-specific operations)TrackerProjectManager (project operations)Batch Operations
Use the batch() method for bulk actions:
$this->trackerClient->batch([
'createTask' => ['projectId' => 123, 'title' => 'Task 1'],
'createTask' => ['projectId' 123, 'title' => 'Task 2'],
]);
| Use Case | Implementation Pattern |
|---|---|
| Log tasks from user actions | Event listeners + TrackerClient |
| Sync local data with Tracker | Cron job + TrackerClient::syncTasks() |
| Custom task fields | Extend TaskDto (see "Extension Points") |
| Project-specific workflows | Use TrackerProjectManager::getProjectTasks() |
API Rate Limits
429 responses:
try {
$this->trackerClient->createTask(...);
} catch (RateLimitExceededException $e) {
sleep($e->getRetryAfter());
retry();
}
Project ID Validation
projectId exists before operations. Use:
$project = $this->trackerClient->getProject($projectId);
if (!$project) throw new \InvalidArgumentException("Project not found");
Field Mapping Quirks
TrackerClient::mapFields():
$mappedTask = $this->trackerClient->mapFields($rawTask, [
'custom_field' => 'entity_property',
]);
Authentication Issues
api_key in config matches Tracker’s API token.api_url includes /api (e.g., https://tracker.com/api/).Enable Verbose Logging
Add to config/packages/monolog.yaml:
handlers:
tracker:
type: stream
path: "%kernel.logs_dir%/tracker.log"
level: debug
channels: ["comindware_tracker"]
Inspect Raw Responses
Use the TrackerClient’s debug mode:
$this->trackerClient->setDebug(true);
$response = $this->trackerClient->getTasks(...);
// Check $response->getDebugInfo() for raw data
Common HTTP Errors
| Error Code | Cause | Solution |
|---|---|---|
| 401 | Invalid API key | Regenerate key in Tracker |
| 403 | Insufficient permissions | Check user role in Tracker |
| 404 | Resource not found | Validate IDs/paths |
| 500 | Server error | Check Tracker server logs |
Custom DTOs
Extend Comindware\TrackerBundle\Model\TaskDto to add project-specific fields:
class CustomTaskDto extends TaskDto
{
public ?string $customField = null;
public function toArray(): array
{
return array_merge(parent::toArray(), [
'custom_field' => $this->customField,
]);
}
}
Event Subscribers
Listen to tracker.task.created or tracker.task.updated:
class TaskSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
TrackerEvents::TASK_CREATED => 'onTaskCreated',
];
}
public function onTaskCreated(TaskEvent $event): void
{
// Custom logic (e.g., notify Slack)
}
}
Override HTTP Client Replace the default Guzzle client by binding your own:
# config/services.yaml
services:
Comindware\TrackerBundle\Client\TrackerClient:
arguments:
$httpClient: '@your_custom_http_client'
Localization
Override translations in translations/messages.en.yaml:
comindware_tracker:
task:
created: "Task '{title}' was successfully created!"
How can I help you explore Laravel packages today?