PHPackages                             andalisolutions/anaf-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. andalisolutions/anaf-php

ActiveLibrary[API Development](/categories/api)

andalisolutions/anaf-php
========================

Description

v0.8.1(9mo ago)9217.3k↓18.1%22[4 issues](https://github.com/andalisolutions/anaf-php/issues)[5 PRs](https://github.com/andalisolutions/anaf-php/pulls)MITPHPPHP ^8.2.0CI passing

Since Jan 14Pushed 4mo ago17 watchersCompare

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

READMEChangelog (10)Dependencies (10)Versions (25)Used By (0)

 [![ANAF PHP](https://raw.githubusercontent.com/andalisolutions/anaf-php/main/art/social.png)](https://raw.githubusercontent.com/andalisolutions/anaf-php/main/art/social.png)

 [![GitHub Workflow Status (main)](https://camo.githubusercontent.com/877aac6cb3248511e431e4c1a24fb9d0d0c6a28e6075641156b13f4c2cec48f1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616e64616c69736f6c7574696f6e732f616e61662d7068702f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d726f756e642d737175617265)](https://github.com/andalisolutions/anaf-php/actions) [![Total Downloads](https://camo.githubusercontent.com/0f3b0112c0801a63588a1c8d8b7fcefd7efe477306d2af204524d8ec33dad5e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e64616c69736f6c7574696f6e732f616e61662d706870)](https://packagist.org/packages/andalisolutions/anaf-php) [![Latest Version](https://camo.githubusercontent.com/7c2f7ad7148371a1d1f0d09d04bced19bca1c6d34d00eea89eccc20d84b88512/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e64616c69736f6c7574696f6e732f616e61662d706870)](https://packagist.org/packages/andalisolutions/anaf-php) [![License](https://camo.githubusercontent.com/c3b5566762aeeec124089b46921b6aae7238a6171c00c6f09482b7c4a1ba80b9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f616e64616c69736f6c7574696f6e732f616e61662d706870)](https://packagist.org/packages/andalisolutions/anaf-php)

---

**ANAF PHP** is a PHP API client that allows you to interact with the [ANAF Web Services](https://www.anaf.ro/anaf/internet/ANAF/servicii_online/servicii_web_anaf).

Get Started
-----------

[](#get-started)

> **Requires [PHP 8.2+](https://php.net/releases/)**

First, install ANAF via the [Composer](https://getcomposer.org/) package manager:

```
composer require andalisolutions/anaf-php
```

Then, you can create `ANAF` client in two ways:

```
/*
 * Client used for unauthenticated requests
 */
$client = Anaf::client();

/*
 * Client used for authenticated requests
 */
$authorizedClient = Anaf::authorizedClient($apiKey);

/*
 * Build a client with a specific base URI, staging and more. Example:
 */
$factoryClient = Anaf::factory()
    ->withApiKey($apiKey)
    ->staging()
    ->withBaseUri('https://webservicesp.anaf.ro')
    ->make();
```

#### You can obtain API key using [oauth2-anaf](https://github.com/andalisolutions/oauth2-anaf) package.

[](#you-can-obtain-api-key-using-oauth2-anaf-package)

TODO
----

[](#todo)

- Obtaining public information in the financial statements/annual accounting reports related to economic agents. ([Docs](https://static.anaf.ro/static/10/Anaf/Informatii_R/doc_WS_Bilant_V1.txt))
- Get info about companies using `TAX IDENTIFICATION NUMBER` (CUI/Vat Number). ([Docs](https://static.anaf.ro/static/10/Anaf/Informatii_R/Servicii_web/doc_WS_V8.txt))
- Get info about taxpayers who are registered in the Register of farmers who apply the special regime ([Docs](https://static.anaf.ro/static/10/Anaf/Informatii_R/documentatie_SWRARG_v2.txt))
- Get info about taxpayers who are registered in the Register of religious entities/units ([Docs](https://static.anaf.ro/static/10/Anaf/Informatii_R/index_cult_v2.html))
- Accessing the functionalities offered by the SPV ([Docs](https://static.anaf.ro/static/10/Anaf/Informatii_R/Prezentare_WS_SPV.txt))
- The national system regarding the electronic invoice RO e-Factura ([Docs](https://mfinante.gov.ro/static/10/eFactura/prezentare%20apeluri%20API%20E-factura.pdf))
- The integrated electronic system RO e-Transport ([Docs](https://www.anaf.ro/anaf/internet/ANAF/servicii_online/servicii_web_anaf))

Usage
-----

[](#usage)

### [Balance Sheet](https://static.anaf.ro/static/10/Anaf/Informatii_R/doc_WS_Bilant_V1.txt) Resource

[](#balance-sheet-resource)

Get public information in the financial statements/annual accounting reports related to economic agents

```
$balanceSheet = $client()->balanceSheet()->create([
    'cui' => '12345678',
    'an' => 2019,
]);

$balanceSheet->year;
$balanceSheet->tax_identification_number;
$balanceSheet->company_name;
$balanceSheet->activity_code;
$balanceSheet->activity_name;
$balanceSheet->indicators; // array
$balanceSheet->indicators['AVERAGE_NUMBER_OF_EMPLOYEES']->value;
$balanceSheet->indicators['NET_LOSS']->value;
$balanceSheet->indicators['NET_PROFIT']->value;
$balanceSheet->indicators['GROSS_LOSS']->value;
$balanceSheet->indicators['GROSS_PROFIT']->value;
$balanceSheet->indicators['TOTAL_EXPENSES']->value;
$balanceSheet->indicators['TOTAL_INCOME']->value;
$balanceSheet->indicators['NET_TURNOVER']->value;
$balanceSheet->indicators['HERITAGE_OF_THE_KINGDOM']->value;
$balanceSheet->indicators['PAID_SUBSCRIBED_CAPITAL']->value;
$balanceSheet->indicators['CAPITAL_TOTAL']->value;
$balanceSheet->indicators['PROVISIONS']->value;
$balanceSheet->indicators['ADVANCE_INCOME']->value;
$balanceSheet->indicators['LIABILITIES']->value;
$balanceSheet->indicators['PREPAYMENTS']->value;
$balanceSheet->indicators['HOME_AND_BANK_ACCOUNTS']->value;
$balanceSheet->indicators['DEBT']->value;
$balanceSheet->indicators['INVENTORIES']->value;
$balanceSheet->indicators['CURRENT_ASSETS']->value;
$balanceSheet->indicators['FIXED_ASSETS']->value;

$balanceSheet->toArray(); // ['year' => '', 'tax_identification_number' => '', 'company_name' => '' ...]
```

*For balance sheets, the indicators may vary depending on the type of company, as specified by ANAF. I recommend you to use var\_dump to observe the type of indicators. The vast majority of companies have the indicators from the example above*

### [Info](https://static.anaf.ro/static/10/Anaf/Informatii_R/Servicii_web/doc_WS_V8.txt) Resource

[](#info-resource)

Get info about the company or multiple companies.

```
$companyInfo = $client->info()->create([
    [
        'cui' => '12345678',
        'data' => '2021-01-01',
    ],
    [
        'cui' => '222222',
        'data' => '2021-01-01',
    ]
]);

/*
 * If you send one array, for one company, you will receive a CreateResponse object with the structure below.
 * If you send multiple arrays, for multiple companies, you will receive a CreateResponses object with an array
 * with CreateResponse objects.
 */

$companyInfo->generalData;

/* Accessible information in general data */
$companyInfo->generalData->companyName;
$companyInfo->generalData->address;
$companyInfo->generalData->registrationNumber;
$companyInfo->generalData->phone;
$companyInfo->generalData->fax;
$companyInfo->generalData->postalCode;
$companyInfo->generalData->document;
$companyInfo->generalData->registrationStatus;
$companyInfo->generalData->registrationDate;
$companyInfo->generalData->activityCode;
$companyInfo->generalData->bankAccount;
$companyInfo->generalData->roInvoiceStatus;
$companyInfo->generalData->authorityName;
$companyInfo->generalData->formOfOwnership;
$companyInfo->generalData->organizationalForm;
$companyInfo->generalData->legalForm;

$companyInfo->vatRegistration;

/* Accessible information in vat registration */
$companyInfo->vatRegistration->status;
//vatPeriods is an array from ANAF v8
$companyInfo->vatRegistration->vatPeriods[0]->startDate
$companyInfo->vatRegistration->vatPeriods[0]->stopDate;
$companyInfo->vatRegistration->vatPeriods[0]->stopEffectiveDate;
$companyInfo->vatRegistration->vatPeriods[0]->message;

$companyInfo->vatAtCheckout;

/* Accessible information in vat at checkout */
$companyInfo->vatAtCheckout->startDate;
$companyInfo->vatAtCheckout->stopDate;
$companyInfo->vatAtCheckout->updateDate;
$companyInfo->vatAtCheckout->publishDate;
$companyInfo->vatAtCheckout->updatedType;
$companyInfo->vatAtCheckout->status;

$companyInfo->inactiveState;

/* Accessible information in inactive state */
$companyInfo->inactiveState->inactivationDate;
$companyInfo->inactiveState->reactivationDate;
$companyInfo->inactiveState->publishDate;
$companyInfo->inactiveState->deletionDate;
$companyInfo->inactiveState->status;

$companyInfo->splitVat;

/* Accessible information in split tva */
$companyInfo->splitVat->startDate;
$companyInfo->splitVat->stopDate;
$companyInfo->splitVat->status;

$companyInfo->hqAddress;

/* Accessible information in hq address */
$companyInfo->hqAddress->street;
$companyInfo->hqAddress->no;
$companyInfo->hqAddress->city;
$companyInfo->hqAddress->cityCode;
$companyInfo->hqAddress->county;
$companyInfo->hqAddress->countyCode;
$companyInfo->hqAddress->countyShort;
$companyInfo->hqAddress->country;
$companyInfo->hqAddress->details;
$companyInfo->hqAddress->postalCode;

$companyInfo->fiscalAddress;

/* Accessible information in fiscal address */
$companyInfo->fiscalAddress->street;
$companyInfo->fiscalAddress->no;
$companyInfo->fiscalAddress->city;
$companyInfo->fiscalAddress->cityCode;
$companyInfo->fiscalAddress->county;
$companyInfo->fiscalAddress->countyCode;
$companyInfo->fiscalAddress->countyShort;
$companyInfo->fiscalAddress->country;
$companyInfo->fiscalAddress->details;
$companyInfo->fiscalAddress->postalCode;

// You can use all resources as array
$companyInfo->toArray(); // ["general_data" => ["tax_identification_number" => '', "company_name" => ''...]..]
// or
$companyInfo->generalData->toArray(); // ['tax_identification_number' => '', 'company_name' => ''...]
```

### [Ngo](https://static.anaf.ro/static/10/Anaf/Informatii_R/index_cult_v2.html) Resource

[](#ngo-resource)

Checking NGO taxpayers who are registered in the Register of religious entities/units

```
$entityInfo = $client->ngo()->create([
    [
        'cui' => '12345678',
        'data' => '2021-01-01',
    ]
]);

$entityInfo->taxIdentificationNumber;
$entityInfo->searchDate;
$entityInfo->entityName;
$entityInfo->address;
$entityInfo->phone;
$entityInfo->postalCode;
$entityInfo->document;
$entityInfo->registrationStatus;
$entityInfo->startDate;
$entityInfo->endDate;
$entityInfo->status;

// You can use all resources as array
$entityInfo->toArray(); // ["tax_identification_number" => '', "entity_name" => ''...]
```

### [eFactura](https://mfinante.gov.ro/web/efactura/informatii-tehnice) Resource

[](#efactura-resource)

#### [Upload](https://mfinante.gov.ro/static/10/eFactura/upload.html) Resource

[](#upload-resource)

Upload an XML (eFactura) file to the SPV

TODO: improve error handling

```
$upload = $authorizedClient->efactura()->upload(
    xml_path: $pathToXmlFile,
    taxIdentificationNumber: '12345678',
    //standard: UploadStandard::UBL, // default value is UBL
    //extern: false, // default value is false
    //selfInvoice: false, // default value is false,
    //b2c: false, // default value is false
);
$upload->responseDate, // 202401011640
$upload->executionStatus,
$upload->uploadIndex,
```

#### [Status](https://mfinante.gov.ro/static/10/eFactura/staremesaj.html) Resource

[](#status-resource)

TODO: implement `status` from [here](https://mfinante.gov.ro/static/10/eFactura/staremesaj.html)

#### [Messages](https://mfinante.gov.ro/static/10/eFactura/listamesaje.html) Resource

[](#messages-resource)

TODO: implement `paginated messages` from [here](https://mfinante.gov.ro/static/10/eFactura/listamesaje.html#/EFacturaListaMesaje/getPaginatie)Get the list of available messages

```
$spvMessages = $authorizedClient->efactura()->messages([
    'zile' => 30, // between 1 and 60
    'cif' => '12345678',
]);

$spvMessages->messages; // array
$spvMessages->serial;
$spvMessages->taxIdentificationNumbers;
$spvMessages->title;

$message = $spvMessages->messages[0];
$message->creationDate,
$message->taxIdentificationNumber,
$message->solicitationId,
$message->details,
$message->type,
$message->id,
```

#### [Download - eFactura XML](https://mfinante.gov.ro/static/10/eFactura/descarcare.html) Resource

[](#download---efactura-xml-resource)

Get a file from the SPV identified by the `id` received from the messages endpoint

```
$file = $authorizedClient->efactura()->download([
    'id' => '12345678',
]);

$file->getContent(); // string - You can save/download the content to a file
```

#### [Validate](https://mfinante.gov.ro/static/10/eFactura/validare.html) Resource

[](#validate-resource)

Validate the XML

```
/*
    * $xmlStandard can be one of the following: 'FACT1', 'FCN'.
    * The default value is 'FACT1'
    */
    $response = $client->efactura()->validateXml($path_to_xml, $xmlStandard);

    $response->isValid(); //bool, you can proceed accordingly
    $response->status; //string 'ok' or 'nok'
    $response->messages; //array  of messages, empty if validation successful

    $response->toArray();
    //Examples
    $valid = [
        'stare'    => 'ok',
        'trace_id' => '....',
    ];

    $invalid = [
        'stare'    => 'nok',
        'Messages' => [
            [
                'message' => "Fisierul transmis nu este valid.....",
            ]
        ],
        'trace_id' => '....',
    ];
```

#### [XmlToPdf](https://mfinante.gov.ro/static/10/eFactura/xmltopdf.html) Resource

[](#xmltopdf-resource)

Convert XML eFactura to PDF. For this endpoint you need to use unauthenticated client

```
/*
 * $xmlStandard can be one of the following: 'FACT1', 'FCN'.
 * The default value is 'FACT1'
 */
$file = $client->efactura()->xmlToPdf($pathToXmlFile, $xmlStandard);
$file->getContent(); // string - You can save the pdf content to a file
```

---

ANAF PHP is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance67

Regular maintenance activity

Popularity44

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.4% 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 ~55 days

Recently: every ~39 days

Total

18

Last Release

272d ago

PHP version history (2 changes)v0.1.0PHP ^8.1.0

v0.8.1PHP ^8.2.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/742128?v=4)[Andrei Ciungulete](/maintainers/ciungulete)[@ciungulete](https://github.com/ciungulete)

---

Top Contributors

[![ciungulete](https://avatars.githubusercontent.com/u/742128?v=4)](https://github.com/ciungulete "ciungulete (73 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (16 commits)")[![robert-stanciu](https://avatars.githubusercontent.com/u/17193524?v=4)](https://github.com/robert-stanciu "robert-stanciu (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")[![Bokor-Attila](https://avatars.githubusercontent.com/u/55798843?v=4)](https://github.com/Bokor-Attila "Bokor-Attila (5 commits)")[![wave84](https://avatars.githubusercontent.com/u/138505472?v=4)](https://github.com/wave84 "wave84 (4 commits)")[![zoltanhorvath2](https://avatars.githubusercontent.com/u/59887383?v=4)](https://github.com/zoltanhorvath2 "zoltanhorvath2 (2 commits)")

---

Tags

anafapicompanyfiscalphpphpsdkanaf

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/andalisolutions-anaf-php/health.svg)

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

###  Alternatives

[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[hubspot/api-client

Hubspot API client

23914.2M16](/packages/hubspot-api-client)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[php-opencloud/openstack

PHP SDK for OpenStack APIs. Supports BlockStorage, Compute, Identity, Images, Networking and Metric Gnocchi

2292.2M24](/packages/php-opencloud-openstack)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)

PHPackages © 2026

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