PHPackages                             i3or1s/efakture - 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. i3or1s/efakture

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

i3or1s/efakture
===============

Library for e-fakture SEF

322PHP

Since Dec 30Pushed 3y ago2 watchersCompare

[ Source](https://github.com/i3or1s/EFakture)[ Packagist](https://packagist.org/packages/i3or1s/efakture)[ RSS](/packages/i3or1s-efakture/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Library for "Sistem elektronskih faktura"
=========================================

[](#library-for-sistem-elektronskih-faktura)

List of services that make use of **SEF API** to send invoices.

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

[](#installation)

- [Install library](https://github.com/i3or1s/EFakture) with Composer
- This library is in beta. Versioning is yet to be supported

Contributing
------------

[](#contributing)

EFakture is an Open Source library that will remain free. You are most welcomed to create issues and pull requests on github.

Licence
-------

[](#licence)

At this moment there is no special licence attached to this product. This will be addressed in the future. There is no intention to limit or in any way disrupt the usage of the library.

Code organization
-----------------

[](#code-organization)

System depends on the UBL standard to create the objects that are to be sent to SEF.
[UBL implementation](https://github.com/i3or1s/UBL) that library depends on.
All responses from the **SEF** are built as objects in the [Model](https://github.com/i3or1s/EFakture/tree/main/src/Model) directory. Storing response results from the **SEF** is currently done in file system. Support for other types of storage is covered through the use of [StorageInterface](https://github.com/i3or1s/EFakture/tree/main/src/Storage/StorageInterface.php)
Cache folder is by default in location `/tmp/sefStorage`.
Some of **SEF** responses are large so API can take some time to cache.

[UBL](https://github.com/i3or1s/EFakture/tree/main/src/UBL) directory contains adapters over standard UBL formats for the purpose of constructing the UBL for **SEF** and removing the complexity of class instantiation.

Example usage
-------------

[](#example-usage)

### Initial setup before every API call

[](#initial-setup-before-every-api-call)

```
$browser = new \React\Http\Browser(); // Used for all the API calls
$apiKey = '*****'; // Obtain key from SEF
$apiService = new \i3or1s\EFakture\Util\EFaktureApi($browser, $apiKey); // Set of available API calls
```

### Retrieve available units

[](#retrieve-available-units)

```
$UnitMeasures = new \i3or1s\EFakture\Service\UnitMeasures();
$measures = $UnitMeasures->retrieve($apiService);
print_r($measures);
```

### Retrieve available companies

[](#retrieve-available-companies)

```
$storageManager = new \i3or1s\EFakture\Storage\StorageManager(new \i3or1s\EFakture\Storage\FileSystemStorage(__DIR__.'/cache'));
$companies = new \i3or1s\EFakture\Service\Companies();
$companiesResourceStream = new \i3or1s\EFakture\ResourceStream\FileSystemResourceStream($storageManager->storage, EFakturaAPIRoutes::GET_ALL_COMPANIES->SEFObject());

$listOfCompanies = $companies->retrieve($apiService, $companiesResourceStream, 0,3);
print_r($listOfCompanies);
```

### Find company

[](#find-company)

For this call to work you should have generated list of companies in the cache.

```
$storageManager = new \i3or1s\EFakture\Storage\StorageManager(new \i3or1s\EFakture\Storage\FileSystemStorage(__DIR__.'/cache', true));
$companies = new \i3or1s\EFakture\Service\Companies();
$companiesResourceStream = new \i3or1s\EFakture\ResourceStream\FileSystemResourceStream($storageManager->storage, EFakturaAPIRoutes::GET_ALL_COMPANIES->SEFObject());

$listOfCompanies = $companiesResourceStream->getStorageInterface()->seek(EFakturaAPIRoutes::GET_ALL_COMPANIES->SEFObject(), [
    "registrationCode" => "08804516"
]);
print_r($listOfCompanies);
```

### Retrieve TAX exemption reasons

[](#retrieve-tax-exemption-reasons)

For this call to work you should have generated list of companies in the cache.

```
$storageManager = new \i3or1s\EFakture\Storage\StorageManager(new \i3or1s\EFakture\Storage\FileSystemStorage(__DIR__.'/cache'));
$taxExemptionListService = new \i3or1s\EFakture\Service\ValueAddedTaxExemptionReasonList();
$taxExemptionResourceStream = new \i3or1s\EFakture\ResourceStream\FileSystemResourceStream($storageManager->storage, EFakturaAPIRoutes::VALUE_ADDED_TAX_EXEMPTION_LIST->SEFObject());
$taxExemptionList = $taxExemptionListService->retrieve($apiService, $taxExemptionResourceStream, 0,1);
print_r($taxExemptionList);
```

### Create and send invoice

[](#create-and-send-invoice)

Note: Company data should be valid in SEF in order for this to work

```
$invoice = new \i3or1s\EFakture\UBL\Invoice(
    new \i3or1s\EFakture\UBL\InvoiceDetails(
        'invoice number (01/2022)', new DateTimeImmutable(), new DateTimeImmutable('+ 7days'), new \i3or1s\EFakture\UBL\CBC\InvoiceTypeCode(\i3or1s\EFakture\UBL\CBC\InvoiceTypeCode::COMMERCIAL_INVOICE),
        'RSD', new \i3or1s\EFakture\UBL\CAC\InvoicePeriod(\i3or1s\EFakture\UBL\CAC\InvoicePeriod::DELIVERY_ACTUAL_DATE),
        '123456', new DateTimeImmutable('+ 7days')

    ),
    new \i3or1s\EFakture\UBL\Party(
        'company PIB', null, 'company name', null, 'city', 'RS',
        'company Identification', 'e-mail address', true
    ),
    new \i3or1s\EFakture\UBL\Party(
        'company PIB', null, 'company name', 'address', 'city',
        'RS','company Identification', 'e-mail address', true
    ),
    new \i3or1s\EFakture\UBL\PaymentMeans(
        '30', '(mod97) 123456/2022', 'Tekući račun pravnog lica'
    ),
    [
        new \i3or1s\EFakture\UBL\TaxSubtotal(2801.15, 20),
        new \i3or1s\EFakture\UBL\TaxSubtotal(1825.28, 10),
        new \i3or1s\EFakture\UBL\TaxSubtotal(1560, 0, null, 'PDV-RS-11-1-4'),
    ],
    6186.43, 6186.43, 6929.19, 0, 0, 6929.19,
    [
        new \i3or1s\EFakture\UBL\InvoiceLine(5, $unitMeasures['MTR'], 560.23, 'test item 1', 20, 1),
        new \i3or1s\EFakture\UBL\InvoiceLine(4, $unitMeasures['KMT'], 456.32, 'test item 2', 10, 2),
        new \i3or1s\EFakture\UBL\InvoiceLine(1, $unitMeasures['H87'], 1560, 'test item 3', 0, 3),
    ]
);

$invoiceService = new \i3or1s\EFakture\Service\Invoice();
$sefResponse = $invoiceService->send($apiService, $invoice);
print_r($sefResponse);
```

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9da9962415a11a30e43b6fc1e62ace69c62db84c0c42b255ea70e8997348a3f3?d=identicon)[i3or1s](/maintainers/i3or1s)

---

Tags

e-faktureefakturephpsef

### Embed Badge

![Health badge](/badges/i3or1s-efakture/health.svg)

```
[![Health](https://phpackages.com/badges/i3or1s-efakture/health.svg)](https://phpackages.com/packages/i3or1s-efakture)
```

###  Alternatives

[anahkiasen/former

A powerful form builder

1.4k1.4M14](/packages/anahkiasen-former)[dagger/dagger

Dagger PHP SDK

261.1k](/packages/dagger-dagger)

PHPackages © 2026

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