adachsoft / task-data-backup
Task, comment, dependency, and attachment data sources for the AdachSoft data-backup library.
Requires
- php: ^8.3
- adachsoft/data-backup-contracts: ^0.2
- adachsoft/task-contracts: ^3.0
Requires (Dev)
- adachsoft/data-backup: ^0.3
- adachsoft/php-code-style: ^0.8.0
- friendsofphp/php-cs-fixer: ^3.95
- nyholm/psr7: ^1.8
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13
- rector/rector: ^2.9
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
adachsoft/task-data-backup provides task, comment, dependency, and attachment data sources for the framework-free adachsoft/data-backup package. The adapters use the adachsoft/task-contracts repository interfaces, so they can be connected to an application's existing persistence layer.
Requirements
- PHP 8.3 or later.
adachsoft/task-contractsandadachsoft/data-backup-contracts(installed automatically as dependencies).- The
adachsoft/data-backup-symfony-bundlepackage to register and run the data sources in a Symfony application. - A PSR-17 stream factory when using the attachment source.
Installation
Install the adapter and the Symfony integration bundle:
composer require adachsoft/task-data-backup adachsoft/data-backup-symfony-bundle
The attachment source requires a PSR-17 stream factory. If the application does not already provide one, install an implementation such as Nyholm PSR-7:
composer require nyholm/psr7
Data sources
| Source ID | Data-backup contract | Depends on | Contents |
|---|---|---|---|
tasks | RecordDataSourceInterface | — | Task fields, checklist, attributes, status, dates, author, parent ID, and version. |
task_dependencies | RecordDataSourceInterface | tasks | Task-to-task dependency relationships. |
comments | RecordDataSourceInterface | tasks | Comments belonging to all exported tasks. |
attachments | BlobDataSourceInterface | tasks | Attachment metadata and binary content. |
The sources use schema version 1. Comments and attachments retain their identifiers during import; task references are resolved through the shared import ID map.
Symfony service registration
Register the data-source services with Symfony's service container and enable autowiring and autoconfiguration. The data-backup-symfony-bundle automatically tags services that implement DataSourceInterface; no manual data-source tag is required. Bind the task-contract repository interfaces to the application's implementations and provide a PSR-17 stream factory for AttachmentDataSource.
For example, in config/services.yaml:
services:
_defaults:
autowire: true
autoconfigure: true
AdachSoft\TaskDataBackup\Source\:
resource: '../vendor/adachsoft/task-data-backup/src/Source/'
AdachSoft\TaskContracts\Interface\TaskRepositoryInterface: '@App\Task\TaskRepository'
AdachSoft\TaskContracts\Interface\CommentRepositoryInterface: '@App\Task\CommentRepository'
AdachSoft\TaskContracts\Interface\AttachmentRepositoryInterface: '@App\Task\AttachmentRepository'
AdachSoft\TaskContracts\Interface\AttachmentContentStorageInterface: '@App\Task\AttachmentContentStorage'
Nyholm\Psr7\Factory\Psr17Factory: ~
Psr\Http\Message\StreamFactoryInterface: '@Nyholm\Psr7\Factory\Psr17Factory'
Replace the example App\Task\... service IDs with the application's repository and content-storage services. If those services are already registered and autowired by their interfaces, keep the existing bindings.
Usage
After configuring a target and archive storage in the bundle, run a backup and restore an archive with the bundle's console commands:
php bin/console data-backup:run
php bin/console data-backup:restore <archive-id>
Use php bin/console data-backup:run --help and php bin/console data-backup:restore --help to see the options supported by the installed bundle version and configured storage.
Missing dependency limitation
MissingReferencePolicyEnum::KEEP cannot preserve a task_dependencies relationship when either endpoint task is missing. TaskRepositoryInterface::addDependency() requires both tasks to exist, so the dependency source reports that unresolved relationship as a failed import instead of storing an orphaned dependency. Use FAIL or SKIP_RECORD when missing dependency endpoints are possible.