adachsoft / task-api-repository
HTTP implementation of the adachsoft/task-contracts repositories backed by adachsoft/task-api.
Requires
- php: ^8.3
- adachsoft/task-contracts: ^2.0
- guzzlehttp/guzzle: ^7.9
Requires (Dev)
- adachsoft/php-code-style: ^0.7.1
- adachsoft/task-functional-tests: ^2.0
- friendsofphp/php-cs-fixer: ^3.89
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.4
- rector/rector: ^2.7
- symplify/phpstan-rules: ^14.9
- vlucas/phpdotenv: ^5.6
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-10-13 09:32:21 UTC
README
HTTP implementation of the adachsoft/task-contracts repositories backed by adachsoft/task-api.
Installation
composer require adachsoft/task-api-repository
The service must expose the /api/v1/repository endpoints and run adachsoft/task-api version 0.6.1 or newer.
Usage
use AdachSoft\TaskApiRepository\Factory\TaskApiRepositoryFactory;
$taskRepository = TaskApiRepositoryFactory::createTaskRepository(
'https://tasks.example.com',
$apiKey,
);
The factory also provides createCommentRepository(). The API key is sent using the X-API-KEY header. Configuration is validated before any request is made.
Error mapping
| API reason | Exception |
|---|---|
task_not_found | TaskNotFoundException |
comment_not_found | CommentNotFoundException |
dependency_not_found | DependencyNotFoundException |
dependency_already_exists | DependencyAlreadyExistsException |
task_already_exists | TaskAlreadyExistsException |
comment_already_exists | CommentAlreadyExistsException |
concurrent_modification | ConcurrentModificationException |
invalid_task_data | InvalidTaskDataException |
contract_violation | InvalidArgumentException |
Unknown API errors and malformed responses are reported as TaskApiRepositoryException.
Optimistic locking
Repository updates use the DTO version field. A ConcurrentModificationException means that another client changed the record; read the record again before retrying an update.
Tests
The test suite runs with:
vendor/bin/phpunit tests
The controlled Docker E2E suite clones adachsoft/task-api at version v0.6.1, installs its dependencies, resets the API storage before each contract test, and starts its Docker Compose test stack automatically:
composer test:e2e-docker
The Docker E2E suite requires Git, Composer, Docker Engine, Docker Compose v2, network access to GitLab, and an available host port 8081. Missing prerequisites or an unavailable API fail the suite; no manual checkout or external API credentials are required.