PHPackages                             valsis/ro-company-lookup - 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. valsis/ro-company-lookup

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

valsis/ro-company-lookup
========================

Lookup Romanian company data by CUI via ANAF public web services.

v0.3.2(3mo ago)09[5 PRs](https://github.com/ValsiS/ro-company-lookup/pulls)MITPHPPHP ^8.3CI passing

Since Jan 26Pushed 2mo agoCompare

[ Source](https://github.com/ValsiS/ro-company-lookup)[ Packagist](https://packagist.org/packages/valsis/ro-company-lookup)[ Docs](https://github.com/ValsiS/ro-company-lookup)[ RSS](/packages/valsis-ro-company-lookup/feed)WikiDiscussions main Synced 1mo ago

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

Ro Company Lookup
=================

[](#ro-company-lookup)

[![Tests](https://camo.githubusercontent.com/9fbceb820726caa60e992a2d720989ebbe2294026ee47caccd2beb9ec11cc414/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f56616c7369532f726f2d636f6d70616e792d6c6f6f6b75702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/ValsiS/ro-company-lookup/actions/workflows/run-tests.yml)[![Validate](https://camo.githubusercontent.com/5948c16a707f9f4df6e9adb9276417ec391130b2af9b4beb887341184e813e58/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f56616c7369532f726f2d636f6d70616e792d6c6f6f6b75702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d76616c6964617465267374796c653d666c61742d737175617265)](https://github.com/ValsiS/ro-company-lookup/actions/workflows/run-tests.yml)[![Latest Version](https://camo.githubusercontent.com/dd2118b60ff23f43f2796c2debc6fafba3373fb2dd010e304fbab8059b0633ee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f56616c7369532f726f2d636f6d70616e792d6c6f6f6b75702e7376673f7374796c653d666c61742d737175617265)](https://github.com/ValsiS/ro-company-lookup/releases)[![PHP Version](https://camo.githubusercontent.com/044112c23f4bbb31925231e147b0123212426b2edab482240691eb7ce3a7955e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e332532422d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://www.php.net/)[![Total Downloads](https://camo.githubusercontent.com/2ba76f3a3ebf1f6bf0078f1d0d62098903335bbf946e6fd978fb87778524ad0a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f56616c7369532f726f2d636f6d70616e792d6c6f6f6b75702f746f74616c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/ValsiS/ro-company-lookup/releases)[![License](https://camo.githubusercontent.com/fd16c201120a9c421bc1de341a26d8465a148b54dac50332beeb395e2102bbbe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f56616c7369532f726f2d636f6d70616e792d6c6f6f6b75702e7376673f7374796c653d666c61742d737175617265)](LICENSE)

A production-ready Laravel package that retrieves Romanian company data by CUI from ANAF public web services. It returns clean DTOs, supports batching, caching, retries, circuit breaker, schema audit, and a very simple developer experience.

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 12+

Compatibility
-------------

[](#compatibility)

PHPLaravelCI8.312.x[![PHP 8.3](https://camo.githubusercontent.com/98f9d9830581d7c4d63ff4d7423a6ab52001b01bc0e1d47da70dc3d6268a06fb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f56616c7369532f726f2d636f6d70616e792d6c6f6f6b75702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d706870253230382e33267374796c653d666c61742d737175617265)](https://github.com/ValsiS/ro-company-lookup/actions/workflows/run-tests.yml)8.512.x[![PHP 8.5](https://camo.githubusercontent.com/3b11e5e9d4541b9ba99533fafcae2f76174a6ea6075994563aeab3ca7ad81a97/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f56616c7369532f726f2d636f6d70616e792d6c6f6f6b75702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d706870253230382e35267374796c653d666c61742d737175617265)](https://github.com/ValsiS/ro-company-lookup/actions/workflows/run-tests.yml)Quick start
-----------

[](#quick-start)

```
composer require valsis/ro-company-lookup
```

```
use Valsis\RoCompanyLookup\Facades\RoCompanyLookup;

return RoCompanyLookup::summaryOrResult('RO12345678');
```

Example response:

```
{
  "exists": true,
  "cui": 12345678,
  "name": "EXEMPLU SRL",
  "caen": "6201",
  "registration_date": "01.01.2020",
  "vat_payer": false,
  "status": "ok",
  "message": null,
  "error": null,
  "code": null
}
```

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

[](#installation)

```
composer require valsis/ro-company-lookup
```

Publish the config file (optional):

```
php artisan vendor:publish --tag=ro-company-lookup-config
```

Configuration
-------------

[](#configuration)

All configuration lives in `config/ro-company-lookup.php`.

Core options:

- `driver`: active driver, default `anaf`
- `timezone`: default query date timezone, default `Europe/Bucharest`
- `language`: output key naming, `ro` or `en`

Date formatting:

- `date_output_format`: fallback output format for dates (default `Y-m-d`)
- `date_output_formats`: per-language formats (default `ro => d.m.Y`, `en => Y-m-d`)

HTTP + ANAF:

- `anaf.base_url`, `anaf.endpoint`, `anaf.timeout`, `anaf.connect_timeout`
- `anaf.retries`, `anaf.backoff_ms`, `anaf.user_agent`

Cache + resilience:

- `cache_store`, `cache_prefix`, `cache_version`
- `cache_ttl_seconds`, `stale_ttl_seconds`
- `use_locks`, `lock_seconds`, `lock_wait_seconds`
- `throttle_seconds` (optional per-CUI guard)

Observability + safety:

- `logging.enabled`, `logging.channel`, `logging.level`
- `schema_audit.enabled`, `schema_audit.fail_on_unknown`, `schema_audit.snapshot_path`
- `circuit_breaker.enabled`, `circuit_breaker.failure_threshold`, `circuit_breaker.cooldown_seconds`

Raw payloads:

- `enable_raw` (include raw ANAF payloads in `meta.raw`)

Usage
-----

[](#usage)

### Standard lookup

[](#standard-lookup)

```
use Valsis\RoCompanyLookup\Facades\RoCompanyLookup;

$company = RoCompanyLookup::lookup('RO123456');
$company = RoCompanyLookup::lookup('123456', new DateTimeImmutable('2024-01-10'));
```

The lookup accepts `RO123`, `ro 123`, or `123` and normalizes to an integer CUI. By default, the query date is "today" in `Europe/Bucharest`.

ANAF mapping is strict to the v9 payload fields (`date_generale`, `inregistrare_scop_Tva`, `adresa_domiciliu_fiscal`, `adresa_sediu_social`, etc.). Legacy/alternate key names are intentionally not mapped.

### Non-throwing API

[](#non-throwing-api)

```
$result = RoCompanyLookup::tryLookup('RO123456');

if ($result->exists()) {
    $company = $result->data;
}
```

### Summary helpers (simplest UX)

[](#summary-helpers-simplest-ux)

```
$summary = RoCompanyLookup::summary('RO123456');
$summary = RoCompanyLookup::summaryOrNull('RO123456'); // null if not found
$summary = RoCompanyLookup::summaryOrFail('RO123456'); // throws on invalid / not found
$summary = RoCompanyLookup::summarySafe('RO123456');   // standard summary payload (never throws)
$summary = RoCompanyLookup::summaryOrResult('RO123456'); // same payload, with status/error metadata
```

### Batch helpers

[](#batch-helpers)

```
$companies = RoCompanyLookup::batch(['RO123', 'RO456'])->get();
$results = RoCompanyLookup::batch(['RO123', 'BAD', 'RO456'])->tryGet();

$summaries = RoCompanyLookup::batchSummary(['RO1', 'RO2']);
$summaries = RoCompanyLookup::batchSummaryWithStatus(['RO1', 'RO2']);
$summaries = RoCompanyLookup::batchSummaryMap(['RO1', 'RO2']);
```

### Validation / normalization

[](#validation--normalization)

```
$isValid = RoCompanyLookup::isValidCui('RO123456');
$normalized = RoCompanyLookup::normalizeCui('  ro  123456 ');
```

After normalization, the CUI must be between 2 and 10 digits. Invalid input returns standardized error codes such as `invalid_cui`, `invalid_cui_too_short`, or `invalid_cui_too_long`.

### Date formatting (global + per request)

[](#date-formatting-global--per-request)

Global (config):

```
// config/ro-company-lookup.php
'date_output_formats' => [
    'ro' => 'd.m.Y',
    'en' => 'Y-m-d',
],
```

Per request override:

```
$formatted = RoCompanyLookup::lookupFormatted('RO123456', format: 'd.m.Y', language: 'ro');
$formatted = RoCompanyLookup::tryLookupFormatted('RO123456', format: 'Y-m-d', language: 'en');
```

DTO structure (high level)
--------------------------

[](#dto-structure-high-level)

The main response is `CompanySimpleData`:

- `company` (CUI, names, trade register, profile)
- `caen` (primary CAEN)
- `address` (fiscal + registered office)
- `contact` (phones, emails)
- `legal` (current + history)
- `vat` (current + history)
- `vat_collection` (TVA la incasare)
- `inactive_status` (inactiv/reactivat)
- `split_vat`
- `meta` (source, query date, cache status, raw)

Company profile (`company.profile`) includes:

- `registration_date`
- `registration_status`
- `fiscal_office`
- `ownership_form`
- `e_invoice_status`
- `e_invoice_registration_date`
- `iban`

Output examples
---------------

[](#output-examples)

### Summary response

[](#summary-response)

```
{
  "exists": true,
  "valid": true,
  "status": "ok",
  "message": null,
  "error": null,
  "code": null,
  "cui": 12345678,
  "name": "EXEMPLU SRL",
  "caen": "6201",
  "registration_date": "01.01.2020",
  "vat_payer": false
}
```

`exists` is true only when `status` is `ok`. `valid` indicates whether the CUI input passed validation.

### Full response (excerpt, RO)

[](#full-response-excerpt-ro)

```
{
  "firma": {
    "cui": 12345678,
    "nr_reg_com": "J2018000000001",
    "denumire": "EXEMPLU SRL",
    "profil": {
      "data_inregistrare": "01.01.2020",
      "stare_inregistrare": "INREGISTRAT din data 01.01.2020"
    }
  },
  "statut_tva": {
    "curent": { "cod": 1, "label": "Neplătitor TVA" }
  },
  "tva_incasare": { "activ": false },
  "stare_inactiv": { "este_inactiv": false },
  "split_tva": { "activ": false },
  "meta": { "sursa": "anaf" }
}
```

Caching, retries, and resilience
--------------------------------

[](#caching-retries-and-resilience)

- Results are cached by driver + CUI + date.
- Default cache TTL is 24 hours.
- When a request fails and a stale cache entry exists (within the configured stale TTL), the stale entry is returned with `meta.is_stale = true`.
- Bump `cache_version` to invalidate cache after mapping changes.
- Retries use exponential backoff and only trigger on 429 and 5xx responses.
- Circuit breaker (optional) opens after repeated 5xx responses and cools down for a configurable interval.
- Optional `throttle_seconds` guards rapid repeated queries per CUI.

Errors
------

[](#errors)

The package throws typed exceptions for error scenarios:

- `InvalidCuiException` for invalid input
- `LookupFailedException` for upstream failures
- `CircuitOpenException` when the circuit is open

For user-facing flows, prefer `tryLookup()` / `trySummary()` helpers.

Artisan commands
----------------

[](#artisan-commands)

```
php artisan ro-company-lookup:check 123456 --date=2024-01-10 --raw
php artisan ro-company-lookup:demo 123456
```

Example output (`ro-company-lookup:check`, fictive data):

```
{
  "adresa": {
    "domiciliu_fiscal": {
      "formatat": "Str. Exemplu, Nr. 10, Mun. Test, Judet IL",
      "judet": "IL",
      "cod_judet": "01",
      "cod_judet_auto": "IL",
      "localitate": "Mun. Test",
      "cod_localitate": "999",
      "strada": "Str. Exemplu",
      "numar": "10",
      "cod_postal": "010101",
      "detalii": null
    },
    "sediu_social": {
      "formatat": "Str. Exemplu, Nr. 10, Mun. Test, Judet IL",
      "judet": "IL",
      "cod_judet": "01",
      "cod_judet_auto": "IL",
      "localitate": "Mun. Test",
      "cod_localitate": "999",
      "strada": "Str. Exemplu",
      "numar": "10",
      "cod_postal": "010101",
      "detalii": null
    }
  },
  "cod_caen": { "cod": "6201", "label": null, "versiune": null },
  "firma": {
    "cui": 12345678,
    "nr_reg_com": "J2018000000001",
    "denumire": "EXEMPLU SRL",
    "profil": {
      "data_inregistrare": "01.01.2020",
      "stare_inregistrare": "INREGISTRAT din data 01.01.2020"
    }
  },
  "statut_tva": {
    "curent": { "cod": 1, "label": "Neplătitor TVA", "data_inceput_tva": null }
  },
  "meta": { "sursa": "anaf", "data_interogare": "01.02.2026", "data_ceruta": "2026-02-01" }
}
```

Example output (`ro-company-lookup:demo`, fictive data):

```
{
  "exists": true,
  "cui": 12345678,
  "name": "EXEMPLU SRL",
  "caen": "6201",
  "registration_date": "2020-01-01",
  "vat_payer": false
}
```

Schema audit
------------

[](#schema-audit)

Enable unknown-key detection and optional snapshots:

```
'schema_audit' => [
    'enabled' => true,
    'fail_on_unknown' => false,
    'snapshot_path' => storage_path('logs/anaf-schema'),
],
```

Documentation
-------------

[](#documentation)

- Full docs: `docs/wiki/Home.md`
- JSON Schemas: `docs/schemas`

Testing
-------

[](#testing)

```
composer test
composer lint
composer analyse
composer ci
```

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md).

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

[](#contributing)

See [CONTRIBUTING.md](CONTRIBUTING.md). Dependabot is enabled.

Code of Conduct
---------------

[](#code-of-conduct)

See [CODE\_OF\_CONDUCT.md](CODE_OF_CONDUCT.md).

Security
--------

[](#security)

See [SECURITY.md](SECURITY.md).

License
-------

[](#license)

The MIT License (MIT). See [LICENSE](LICENSE).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance83

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.2% 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

13

Last Release

105d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/80412daad7a18857b414211a79751d1211f1eb6e18a1739816b3498584e0a7ec?d=identicon)[ValsiS](/maintainers/ValsiS)

---

Top Contributors

[![ValsiS](https://avatars.githubusercontent.com/u/825248?v=4)](https://github.com/ValsiS "ValsiS (55 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

laravelpackagelookupcompanyCUIanafRomania

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/valsis-ro-company-lookup/health.svg)

```
[![Health](https://phpackages.com/badges/valsis-ro-company-lookup/health.svg)](https://phpackages.com/packages/valsis-ro-company-lookup)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[spatie/laravel-rdap

Perform RDAP queries in a Laravel app

72108.3k2](/packages/spatie-laravel-rdap)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)

PHPackages © 2026

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