PHPackages                             weaf/efris-sdk-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. [API Development](/categories/api)
4. /
5. weaf/efris-sdk-php

ActiveLibrary[API Development](/categories/api)

weaf/efris-sdk-php
==================

Modern PHP SDK for WEAF EFRIS integration in Uganda

v1.1.4(1mo ago)02↓50%MITPHPPHP &gt;=7.4

Since Jun 11Pushed 1mo agoCompare

[ Source](https://github.com/emmanuelwandera8/weaf-efris-sdk-php)[ Packagist](https://packagist.org/packages/weaf/efris-sdk-php)[ RSS](/packages/weaf-efris-sdk-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (6)DependenciesVersions (7)Used By (0)

WEAF EFRIS PHP SDK
==================

[](#weaf-efris-php-sdk)

A modern, object-oriented PHP SDK for integrating with the WEAF EFRIS API. This SDK makes it simple to communicate with Uganda Revenue Authority's Electronic Fiscal Receipting and Invoicing System (EFRIS) with standard namespaces, strong exception handling, namespaced resources, and robust network resilience out of the box.

---

Features
--------

[](#features)

- **Clean Namespaces:** Grouped operations under logical properties (`invoices`, `products`, `stock`, `taxpayer`).
- **Token Lifecycle Helpers:** Simplified API Token generation, validation, and refresh.
- **Strict Exception Handling:** Specialized exceptions (`WeafValidationException`, `WeafApiException`) returning exact validation errors and status codes.
- **Automatic Retries:** Auto-retries on connection timeouts and transient gateway issues.
- **PSR-4 Compliant:** Standard namespaces and easily autoloadable in modern frameworks (Laravel, Symfony, etc.).

---

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

[](#installation)

### 1. Installation via Packagist (Recommended)

[](#1-installation-via-packagist-recommended)

You can install the SDK as a standard dependency from Packagist:

```
composer require weaf/efris-sdk-php
```

### 2. Installation via Local Composer Repository

[](#2-installation-via-local-composer-repository)

If you've placed this SDK inside your main project directory, you can add it to your main project's `composer.json` using local repository mapping:

```
"repositories": [
    {
        "type": "path",
        "url": "weaf-efris-sdk-php"
    }
],
"require": {
    "weaf/efris-sdk-php": "*@dev"
}
```

Then run:

```
composer update weaf/efris-sdk-php
```

### 3. Manual Installation

[](#3-manual-installation)

If not using Composer autoloading, you can register a simple manual PSR-4 autoloader:

```
spl_autoload_register(function ($class) {
    $prefix = 'Weaf\\Efris\\';
    $base_dir = __DIR__ . '/weaf-efris-sdk-php/src/';

    $len = strlen($prefix);
    if (strncmp($prefix, $class, $len) !== 0) return;

    $relative_class = substr($class, $len);
    $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';

    if (file_exists($file)) {
        require $file;
    }
});
```

---

Quick Start Guide
-----------------

[](#quick-start-guide)

### 1. Client Initialization

[](#1-client-initialization)

Initialize with a pre-generated authentication token and a default TIN context:

```
use Weaf\Efris\Client;

$client = new Client([
    'token' => 'YOUR_64_CHARACTER_API_TOKEN',
    'defaultTin' => '1000251604',
    'environment' => 'sandbox' // or 'production'
]);
```

Alternatively, initialize using account credentials to generate tokens dynamically:

```
$client = new Client([
    'username' => 'services@weafcompany.com',
    'password' => 'SecurePassword123',
    'defaultTin' => '1000251604',
    'environment' => 'sandbox'
]);

// Dynamically generate a token valid for 30 days
$token = $client->generateAccessToken(30, 'POS Web Integration');
```

---

Common Use Cases
----------------

[](#common-use-cases)

### 1. Search Taxpayer Details

[](#1-search-taxpayer-details)

```
try {
    $taxpayer = $client->taxpayer->search('1000251605');
    print_r($taxpayer['data']);
} catch (\Weaf\Efris\Exceptions\WeafException $e) {
    echo "Error searching taxpayer: " . $e->getMessage();
}
```

### 2. Generate Fiscal Invoice

[](#2-generate-fiscal-invoice)

```
use Weaf\Efris\Exceptions\WeafValidationException;
use Weaf\Efris\Exceptions\WeafApiException;

$invoicePayload = [
    'data' => [
        'sellerDetails' => [
            'placeOfBusiness' => 'Kampala Road',
            'referenceNo' => 'REF-' . time()
        ],
        'basicInformation' => [
            'operator' => 'Cashier 01',
            'currency' => 'UGX',
            'invoiceType' => 1,
            'invoiceKind' => 1,
            'paymentMode' => '101',
            'invoiceIndustryCode' => '101'
        ],
        'buyerDetails' => [
            'buyerTin' => '1000251605',
            'buyerBusinessName' => 'Test Business Customer',
            'buyerType' => '0'
        ],
        'itemsBought' => [
            [
                'itemCode' => 'ITEM001',
                'quantity' => 1,
                'unitPrice' => 100000,
                'total' => 100000,
                'taxForm' => '101',
                'taxRule' => 'STANDARD',
                'netAmount' => 84745.76,
                'taxAmount' => 15254.24,
                'grossAmount' => 100000
            ]
        ]
    ]
];

try {
    $response = $client->invoices->create($invoicePayload);
    $invoiceNo = $response['data']['invoiceNo'];
    $fdn = $response['data']['fdn'];

    echo "Fiscal Invoice Generated: {$invoiceNo} (FDN: {$fdn})";
} catch (WeafValidationException $e) {
    echo "Validation failed: " . $e->getMessage() . "\n";
    print_r($e->getErrors()); // Key-value map of field validation messages
} catch (WeafApiException $e) {
    echo "API request error (Code {$e->getReturnCode()}): " . $e->getMessage();
} catch (\Exception $e) {
    echo "General system error: " . $e->getMessage();
}
```

### 3. Product Catalog Management

[](#3-product-catalog-management)

Register new products or update existing products with the EFRIS (Electronic Fiscal Receipting and Invoicing Solution) system. This allows you to submit product/service details to the Uganda Revenue Authority (URA) for tax compliance and fiscal receipting purposes.

#### Prerequisites

[](#prerequisites)

- A valid EFRIS API access token.
- Company TIN must be configured and active in your account context.

#### Field Specifications

[](#field-specifications)

Field NameTypeRequirementDescription / Value`goodsName`String**Required**The name of the product or service.`goodsCode`String**Required**The unique code identifying the product.`measureUnit`String**Required**The primary unit of measure (e.g., `PCE` for pieces, `DZN` for dozen).`unitPrice`String**Required**Price per primary unit.`currency`String**Required**Currency code (e.g., `101` for Uganda Shillings - UGX).`commodityCategoryId`String**Required**URA Commodity Category Code (must pass the category code, not the name).`haveExciseTax`String**Required**Excise tax flag: `101` (Yes) or `102` (No).`description`String**Required**A brief description of the product or service.`stockPrewarning`String**Required**Threshold quantity for low stock warnings.`havePieceUnit`String**Required**Dual unit indicator: `101` (supports 2 units) or `102` (1 unit only).`operationType`StringOptional`101` for New Registration (default) or `102` for Updating existing.`pieceMeasureUnit`StringOptionalSecondary measure unit code (required if `havePieceUnit` is `101`).`pieceUnitPrice`StringOptionalPrice per secondary unit (required if `havePieceUnit` is `101`).`packageScaledValue`StringOptionalMain package conversion ratio (required if `havePieceUnit` is `101`, usually `1`).`pieceScaledValue`StringOptionalSecondary package conversion ratio (required if `havePieceUnit` is `101`, e.g. `12` pieces).`exciseDutyCode`StringOptionalExcise duty code if applicable.Note

**Exports (Customs Fields):** For exported products, include the customs-specific fields: `customsMeasureUnit`, `customsScaledValue`, `customsUnitPrice`, and `packageScaledValueCustoms`. When updating existing exported items, set `operationType` to `"102"` and include these fields to keep customs data synchronized.

#### Sample Category Codes

[](#sample-category-codes)

Category CodeCategory NameType**81111810**Software coding serviceServices**90101501**RestaurantsServices**50202306**Soft drinksInventory / Products**53131619**CosmeticsInventory / Products**95141708**Office kitchenInventory / Products**11121604**Soft timberInventory / Products#### Unit of Measure Payload Scenarios

[](#unit-of-measure-payload-scenarios)

##### Scenario A: Single Unit of Measure (1 Unit)

[](#scenario-a-single-unit-of-measure-1-unit)

If the item supports only one unit of measure, set `havePieceUnit` to `"102"` and pass empty strings `""` for the secondary unit fields:

```
$client->products->register([
    'products' => [
        [
            'goodsName' => 'Software Coding Service',
            'goodsCode' => 'SRV-SW-01',
            'measureUnit' => 'PCE',
            'unitPrice' => '150000',
            'currency' => '101',
            'commodityCategoryId' => '81111810',
            'haveExciseTax' => '102',
            'description' => 'Custom software coding services per hour',
            'stockPrewarning' => '1',
            'havePieceUnit' => '102', // Single unit of measure
            'pieceMeasureUnit' => '',
            'pieceUnitPrice' => '',
            'packageScaledValue' => '',
            'pieceScaledValue' => '',
            'exciseDutyCode' => '',
            'operationType' => '101'
        ]
    ]
]);
```

##### Scenario B: Dual Unit of Measure (2 Units)

[](#scenario-b-dual-unit-of-measure-2-units)

If the item supports two units of measure (e.g. buying/selling in dozens and pieces), set `havePieceUnit` to `"101"` and fill in the secondary unit details:

```
$client->products->register([
    'products' => [
        [
            'goodsName' => 'Sample Deemed Item',
            'goodsCode' => 'DEEMED-001',
            'measureUnit' => 'DZN', // Main unit (Dozen)
            'unitPrice' => '10000', // Price per dozen
            'currency' => '101',
            'commodityCategoryId' => '10111301',
            'haveExciseTax' => '102',
            'description' => 'Deemed goods with dual units of measure support',
            'stockPrewarning' => '1',
            'havePieceUnit' => '101', // Supports dual units
            'pieceMeasureUnit' => 'PCE', // Secondary unit (Piece)
            'pieceUnitPrice' => '1000', // Price per piece
            'packageScaledValue' => '1', // 1 dozen conversion
            'pieceScaledValue' => '12', // Equals 12 pieces
            'exciseDutyCode' => '',
            'operationType' => '101'
        ]
    ]
]);
```

##### Listing Registered Products

[](#listing-registered-products)

```
// Retrieve the list of all registered goods and services
$products = $client->products->list();
```

### 4. Stock Adjustments

[](#4-stock-adjustments)

```
// Record local inventory intake (Stock In)
$client->stock->increase([
    'remarks' => 'Monthly inventory intake',
    'stockInDate' => date('Y-m-d'),
    'stockInType' => '102', // 102 = Local Purchase
    'stockInItem' => [
        [
            'itemCode' => 'SW-PKG-01',
            'quantity' => 200,
            'unitPrice' => 100000
        ]
    ],
    'supplierName' => 'Software Distributor Uganda',
    'supplierTin' => '1017196396'
]);
```

---

Technical Support &amp; Reference
---------------------------------

[](#technical-support--reference)

- **API Base URL (Default):** `https://weafcompany.com/api`
- **Documentation Portal:**
- **Technical Support:**

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance90

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

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

Every ~0 days

Total

6

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0bb37459d3df02bb71744405754217e41ccf298323a8ffbbe1314f3d9747025e?d=identicon)[weafcompany](/maintainers/weafcompany)

---

Top Contributors

[![emmanuelwandera8](https://avatars.githubusercontent.com/u/47532031?v=4)](https://github.com/emmanuelwandera8 "emmanuelwandera8 (8 commits)")

### Embed Badge

![Health badge](/badges/weaf-efris-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/weaf-efris-sdk-php/health.svg)](https://phpackages.com/packages/weaf-efris-sdk-php)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k18](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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