adachsoft / task-json-file
JSON file implementation of adachsoft/task-contracts
Requires
- php: ^8.3
- adachsoft/task-contracts: ^2.0
Requires (Dev)
- adachsoft/php-code-style: ^0.7.1
- adachsoft/task-functional-tests: ^2.0
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^13.0
- rector/rector: ^2.6
- symplify/phpstan-rules: ^14.17
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-10-21 03:48:05 UTC
README
A JSON file implementation of the adachsoft/task-contracts repository interfaces.
Features
- Persist tasks and comments in JSON files.
- Add, update, delete, and find tasks and comments by identifier.
- Allocate the next task or comment identity.
- Build task trees.
- Manage task dependencies.
- Count children and comments for multiple tasks.
- Protect read-modify-write operations with exclusive file locking.
- Detect concurrent updates with optimistic version checks.
Installation
composer require adachsoft/task-json-file
Usage
<?php
declare(strict_types=1);
use AdachSoft\TaskJsonFile\Repository\JsonTaskRepository;
$repository = new JsonTaskRepository(__DIR__ . '/var/tasks.json');
$task = $repository->findById('task1');
$rootTasks = $repository->findByParentId(null);
The repository implements AdachSoft\TaskContracts\Interface\TaskRepositoryInterface and stores data in the JSON file path provided to the constructor. Use add() for inserts and save() for compare-and-swap updates; persisted entities are versioned starting at version 1.
Use AdachSoft\TaskJsonFile\Repository\JsonCommentRepository to persist and query comments associated with tasks. Both repositories perform mutations atomically while holding an exclusive lock on the JSON file.
See docs/examples/ for complete usage examples.
Requirements
- PHP 8.3 or newer
adachsoft/task-contracts
License
This project is released under the MIT License.