tigamadou/emecef-core-php

Framework-agnostic Core SDK for the Benin Republic e-MECeF (Electronic Tax Invoice) system

Maintainers

Package info

github.com/tigamadou/emecef-core-php

pkg:composer/tigamadou/emecef-core-php

Statistics

Installs: 8

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v0.0.2 2026-03-08 17:29 UTC

This package is auto-updated.

Last update: 2026-03-08 17:29:58 UTC


README

Framework-agnostic Core SDK for the Benin Republic e-MECeF (Electronic Tax Invoice) system.

Part of the e-MECeF SDK ecosystem. This package contains all e-MECeF protocol logic; framework adapters (Laravel, Symfony, etc.) and CMS plugins depend on it and must not reimplement business rules.

Requirements

  • PHP ≥ 8.2

Installation

composer require tigamadou/emecef-core-php

Or from the monorepo (development):

cd php/packages/core/emecef-core
composer install

Quick Start

The Core does not read configuration. You inject base URL, JWT token, an HTTP client implementation, and a logger:

use Emecef\Core\Client;
use Emecef\Core\Contract\HttpClientInterface;
use Emecef\Core\Contract\LoggerInterface;

$client = new Client(
    baseUrl: 'https://sygmef.impots.bj/emcf/api/invoice',
    token: 'your-jwt-from-dgi',
    httpClient: $yourHttpClient,  // must implement HttpClientInterface
    logger: $yourLogger          // must implement LoggerInterface
);

For full configuration and usage, see the docs in this package:

Data objects (DTOs) and enums

The package models all request and response structures from the e-MECeF API v1.0 specification. For field-by-field descriptions and request/return shapes, see DTOs and API reference:

  • Enums: Emecef\Core\Enum\InvoiceType, AibGroupType, TaxGroupType, PaymentType
  • Request DTOs (build payloads, call toArray() or toJson()): Emecef\Core\Dto\Request\InvoiceRequestDataDto, ItemDto, ClientDto, OperatorDto, PaymentDto
  • Response DTOs (create from API array via fromArray()): Emecef\Core\Dto\Response\StatusResponseDto, PendingRequestDto, InvoiceResponseDataDto, SecurityElementsDto

You can use the client with raw JSON (array in/out) or with typed DTOs:

// Array-based (unchanged)
$status = $client->getStatus();           // array
$result = $client->submitInvoice($json); // array
$client->confirm($uid);                   // array
$client->cancel($uid);                   // array

// DTO-based (typed request/response)
$statusDto = $client->getStatusResponse();                    // StatusResponseDto
$requestDto = new InvoiceRequestDataDto(...);                // build request
$responseDto = $client->submitInvoiceRequest($requestDto);   // InvoiceResponseDataDto
$securityDto = $client->confirmResponse($uid);               // SecurityElementsDto
$cancelDto = $client->cancelResponse($uid);                  // SecurityElementsDto

Package Rules

  • Framework-agnostic: No Laravel, Symfony, or CMS dependencies.
  • No env access: Configuration is passed in by the caller.
  • Transport abstraction: HTTP via HttpClientInterface; logging via LoggerInterface.

Development

composer install
composer phpcs         # code style check (mandatory)
composer phpcbf       # code style fix (mandatory)
composer phpmd        # mess detector (mandatory)
composer test
composer phpstan
  • Code style: PHP_CodeSniffer (phpcs + phpcbf) mandatory; PSR-12.
  • Mess detection: PHPMD mandatory.
  • Tests: PHPUnit, unit tests only; coverage target ≥ 95%.
  • Static analysis: PHPStan (max level).

License

Proprietary. See repository root for governance.