tigamadou/emecef-laravel

Laravel adapter for the e-MECeF (Electronic Tax Invoice) SDK – Benin Republic

Maintainers

Package info

github.com/tigamadou/emecef-laravel

pkg:composer/tigamadou/emecef-laravel

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

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

This package is auto-updated.

Last update: 2026-03-08 17:41:17 UTC


README

Laravel adapter for the Benin Republic e-MECeF (Electronic Tax Invoice) SDK. It wires emecef-core-php into Laravel via config, a facade, and Laravel’s HTTP and logging.

Part of the e-MECeF SDK ecosystem.

Requirements

Installation

composer require tigamadou/emecef-laravel

The package auto-registers its service provider and the Emecef facade (Laravel 11+ package discovery). For older Laravel, add the provider and alias in config/app.php if needed.

Configuration

  1. Publish the config file:

    php artisan vendor:publish --tag=emecef-config
  2. Store token, ifu, nim, and environment in the emecef_config table (see migrations). Config file is for Laravel-specific options only (e.g. log_channel).

  3. Publish and run migrations to create invoice and config tables:

    php artisan vendor:publish --tag=emecef-migrations
    php artisan migrate

    Models: Emecef\Laravel\Models\EmecefConfig, EmecefInvoice, EmecefInvoiceItem, EmecefInvoicePayment

  4. Optionally set log_channel for e-MECeF logs.

  5. (Optional) Publish views to customize the web interface:

    php artisan vendor:publish --tag=emecef-views

    Views are copied to resources/views/vendor/emecef.

See docs/configuration.md for the full config reference.

Web interface

The package includes a web interface for all e-MECeF actions. After migrations and config, visit /{prefix}/ (default: /emecef/):

Route Action
GET /emecef/ Dashboard (API status, recent invoices)
GET /emecef/invoices List invoices
GET /emecef/invoices/create Create invoice form
GET /emecef/invoices/{id} View invoice (confirm/cancel if pending)
GET /emecef/config View configuration
GET /emecef/config/edit Create or edit configuration (single row)

Configure route_prefix and route_middleware in config/emecef.php. See docs/configuration.md.

Quick start

Use the facade or inject Emecef\Core\Client:

use Emecef\Laravel\Facades\Emecef;

$status = Emecef::getStatusResponse();
use Emecef\Core\Client;

public function __construct(private readonly Client $emecef) {}
// $this->emecef->getStatusResponse(), submitInvoiceRequest(), confirmResponse(), cancelResponse(), etc.

All operations and DTOs are the same as in the core package. Example: submit an invoice and confirm:

use Emecef\Core\Dto\Request\InvoiceRequestDataDto;
use Emecef\Core\Dto\Request\ItemDto;
use Emecef\Core\Dto\Request\OperatorDto;
use Emecef\Core\Enum\InvoiceType;
use Emecef\Core\Enum\TaxGroupType;
use Emecef\Laravel\Facades\Emecef;

$request = new InvoiceRequestDataDto(
    ifu: '9999900000001',
    type: InvoiceType::FV,
    items: [
        new ItemDto('Article A', 1000, 2.0, TaxGroupType::A),
    ],
    operator: new OperatorDto('Opérateur 1')
);
$response = Emecef::submitInvoiceRequest($request);
if ($response->uid !== null) {
    $security = Emecef::confirmResponse($response->uid);
    // $security->qrCode, $security->codeMECeFDGI for the printed invoice
}

See docs/examples.md for more examples and error handling.

Documentation

Document Description
Overview What the package does and does not do, dependencies
Configuration Config file, routes, views, and how the client is built
Examples Facade, dependency injection, web interface, submit/confirm/cancel, errors
Schema Full database schema with API field mapping and descriptions
Core: DTOs and API All enums, request/response DTOs, and API operations

What this package provides

  • Config: config/emecef.php with log channel, route prefix, and route middleware.
  • Bindings: HttpClientInterface → Laravel HTTP client, LoggerInterface → Laravel Log (optional channel), Client as singleton.
  • Facade: Emecef\Laravel\Facades\EmecefEmecef\Core\Client.
  • Web interface: Dashboard, invoice list/create/show, config management. Views are publishable (emecef-views).
  • Routes: Prefixed by route_prefix (default emecef), protected by route_middleware (default web).

Business logic, DTOs, and API contract live in emecef-core-php; this adapter only integrates them with Laravel.

Development

composer install
composer phpcs
composer phpcbf
composer phpmd
composer test
composer phpstan
  • Code style: PHP_CodeSniffer (PSR-12).
  • Mess detection: PHPMD.
  • Tests: PHPUnit (Orchestra Testbench).
  • Static analysis: PHPStan.

License

Proprietary. See repository root for governance.