PHPackages                             grinchenkoedu/diia-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. grinchenkoedu/diia-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

grinchenkoedu/diia-php
======================

Unofficial Diia library for PHP

1.0.0(1y ago)213MITPHPPHP &gt;=7.4

Since Aug 26Pushed 1y ago2 watchersCompare

[ Source](https://github.com/grinchenkoedu/diia-php)[ Packagist](https://packagist.org/packages/grinchenkoedu/diia-php)[ RSS](/packages/grinchenkoedu-diia-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

\[Unofficial\] Diia (Дія) API Client for PHP
============================================

[](#unofficial-diia-дія-api-client-for-php)

[![CI workflow](https://github.com/grinchenkoedu/diia-php/actions/workflows/tests.yml/badge.svg)](https://github.com/grinchenkoedu/diia-php/actions/workflows/tests.yml/badge.svg)

This library is not official, no parts are provided or approved by Diia developers.

Installation
------------

[](#installation)

```
composer require grinchenkoedu/diia-php
```

Recommended libraries
---------------------

[](#recommended-libraries)

- [ramsey/uuid](https://github.com/ramsey/uuid) - for UUID generation
- [matasarei/euspe](https://github.com/matasarei/euspe) - cryptographic library

Examples
--------

[](#examples)

The client library does not implement callback handlers, only API calls.

### Client initialization

[](#client-initialization)

The next code should be encapsulated in a service provider or a factory.

```
/** @var \GuzzleHttp\Client $httpClient */
$httpClient = new Client([
    'base_uri' => 'http://api.dev.lan', // replace with actual API URL
    'timeout'  => 2.0,
]);

$tokenProvider = new BearerTokenProvider(
    new AuthClient($httpClient),
    new Credentials('token', 'auth_token'),
    $cacheInterface // PSR cache interface
);

$globalScopes = (new Scopes())
    ->addScopes(ScopesDiiaId::NAME, ScopesDiiaId::SCOPES_ALL)
    ->addScopes(ScopesSharing::NAME, [
        // any sharing scopes if needed
    ])
;

$scopesMapper = new ScopesMapper($globalScopes);
$branchMapper = new BranchMapper($scopesMapper);
$offerMapper = new OfferMapper($scopesMapper);

$dependencyResolver = (new DependencyResolver())
    ->addDependency(new ItemsListRequestMapper())
    ->addDependency($branchMapper)
    ->addDependency($offerMapper)
    ->addDependency(new OfferRequestMapper())
;
$requestJsonMapper = new RequestJsonMapper($dependencyResolver);

$client = new AcquirersClient(
    $httpClient,
    new HttpHeadersProvider($tokenProvider),
    $requestJsonMapper,
    new ResponseJsonMapper(new ApiResourceMapper()),
    new ResponseJsonMapper(
        new ItemsListResponseMapper('branches', $branchMapper)
    ),
    new ResponseJsonMapper($branchMapper),
    new ResponseJsonMapper(
        new ItemsListResponseMapper('offers', $offerMapper)
    ),
    new ResponseJsonMapper(new OfferResponseMapper())
);
```

### Branches

[](#branches)

```
// Branch of the organization
$branch = new Branch(
    'Branch name', // like "Head Office"
    'Branch location', // like "City"
    'Branch street', // like "Street"
    'Branch building' // like "1"
);

$resource = $client->createBranch($branch);
$branchId = $resource->getId();

// The branches can be also updated or deleted.
// To update scopes branches must be removed and created again (see $globalScopes).
$client->updateBranch($branchId, $branch);
$client->deleteBranch($branchId);
```

### Дія.Підпис

[](#діяпідпис)

```
// Define scopes.
$scopes = new Scopes();
$scopes->addScopes(
    ScopesDiiaId::NAME, [
        ScopesDiiaId::SCOPE_HASHED_FILES_SIGNING,
    ]
);

// Add a new offer.
$offer = new Offer('Document description');
$offer->setScopes($scopes);

/** @var \GrinchenkoUniversity\Diia\Dto\ApiResource $apiResource */
$apiResource = $client->createOffer($branchId, $offer);
// You need to save the ID of the offer for future use.
$offerId = $apiResource->getId();

$offerRequest = new OfferRequest(
    $offerId,
    $requestId // UUID4, must be previously generated and saved
);

$crypto = new Matasar\Euspe\Crypto(); // from matasarei/euspe
$documentHash = $crypto->hashFile('/path/to/file.pdf'); // not only PDF

$offerRequest
    ->addFile('filename', $documentHash)
    ->setSignAlgo(OfferRequest::SIGN_ALGO_DSTU)
    ->setReturnLink('https://example.com/return') // users return link, optional
;

$offerResponse = $client->makeOfferRequest($branchId, $offerId);

// Users deep link to sign the document.
var_dump($offerResponse->getDeepLink());
```

### Дія.Шеринг

[](#діяшеринг)

```
// Define scopes
$scopes = new Scopes();
$scopes->addScopes(ScopesSharing::NAME, [
    // list of scopes (documents) to share
])

$offer = new Offer('Reason to get document');
$offer->setScopes($scopes);

/** @var \GrinchenkoUniversity\Diia\Dto\ApiResource $apiResource */
$apiResource = $client->createOffer($brancId, $offer);

$offerRequest = new OfferRequest(
    $apiResource->getId(), // you need to save the ID of the offer for future use
    $requestId // UUID4, must be previously generated and saved
);
$offerRequest
    ->setUseDiia(true)
    ->setReturnLink('https://example.com/return') // users return link, optional
;

/** @var \GrinchenkoUniversity\Diia\Dto\Response\OfferResponse $offerResponse */
$offerResponse = $client->makeOfferRequest($brancId, $offerRequest);

// Users deep link to share document(s).
var_dump($offerResponse->getDeepLink());
```

Tests and development
---------------------

[](#tests-and-development)

1. Install vendors

```
docker run --rm -v $(pwd):/app -w /app composer:lts composer install
```

2. Run tests

```
docker run --rm -v $(pwd):/app -w /app composer:lts vendor/bin/phpunit
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

621d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/44632227efd38dd8598ceb71812e223865e994f1f35f027b423469133fb29d6b?d=identicon)[matasarei](/maintainers/matasarei)

---

Top Contributors

[![matasarei](https://avatars.githubusercontent.com/u/6638367?v=4)](https://github.com/matasarei "matasarei (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/grinchenkoedu-diia-php/health.svg)

```
[![Health](https://phpackages.com/badges/grinchenkoedu-diia-php/health.svg)](https://phpackages.com/packages/grinchenkoedu-diia-php)
```

###  Alternatives

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

22.8k69.3k](/packages/grumpydictator-firefly-iii)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k17](/packages/civicrm-civicrm-core)[bakame/laravel-domain-parser

Laravel package to integrate PHP Domain parser.

26534.8k4](/packages/bakame-laravel-domain-parser)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
