PHPackages                             hlrlookup/php-sdk - 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. hlrlookup/php-sdk

ActiveLibrary

hlrlookup/php-sdk
=================

PHP SDK for the HLR Lookup API - HLR, MNP, and Number Validation lookups

v1.1.0(1mo ago)02↑1400%MITPHPPHP &gt;=8.1CI passing

Since Mar 16Pushed 1mo agoCompare

[ Source](https://github.com/hlrlookup-com/hlrlookup-php-sdk)[ Packagist](https://packagist.org/packages/hlrlookup/php-sdk)[ Docs](https://www.hlrlookup.com)[ RSS](/packages/hlrlookup-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

HLR Lookup PHP SDK
==================

[](#hlr-lookup-php-sdk)

[![Tests](https://github.com/hlrlookup-com/hlrlookup-php-sdk/actions/workflows/tests.yml/badge.svg)](https://github.com/hlrlookup-com/hlrlookup-php-sdk/actions/workflows/tests.yml)[![Latest Version](https://camo.githubusercontent.com/794e1cfe244ffce8585141e99dcf7df9022dfaeaf83bf3a8d89e7c46c0c4784e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686c726c6f6f6b75702f7068702d73646b2e737667)](https://packagist.org/packages/hlrlookup/php-sdk)[![PHPStan](https://camo.githubusercontent.com/2761aeebb3945f1ca4e4b0f156a71a3558c10dd6e3da83b1feb44f4d33013329/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230362d627269676874677265656e2e737667)](https://phpstan.org/)[![PHP](https://camo.githubusercontent.com/7535257ca228724c93658bd52583d4e47a9bab02c356abf6e54c1d575f2151e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c75652e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

The official PHP SDK for the [HLR Lookup API](https://www.hlrlookup.com) — HLR, MNP, and Number Validation lookups.

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

[](#requirements)

- PHP 8.1+
- ext-json

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

[](#installation)

```
composer require hlrlookup/php-sdk
```

Quick Start
-----------

[](#quick-start)

```
use HlrLookup\HlrLookup;
use HlrLookup\Config;

$hlr = new HlrLookup(new Config('your-api-key', 'your-api-secret'));

// Single number lookup
$results = $hlr->hlr('+447540822872');

$result = $results[0];
echo $result->liveStatus->value;          // "LIVE"
echo $result->telephoneNumberType->value; // "MOBILE"
echo $result->isLive();                   // true
echo $result->isPorted();                 // true/false
```

Lookup Types
------------

[](#lookup-types)

```
// HLR Lookup (full live status check) - 1 credit
$results = $hlr->lookups()->hlr('447540822872');

// MNP Lookup (number portability only) - 0.5 credits
$results = $hlr->lookups()->mnp('447540822872');

// Number Validation
$results = $hlr->lookups()->validate('447540822872');
```

Multiple Numbers
----------------

[](#multiple-numbers)

Up to 80 numbers per request:

```
$results = $hlr->hlr('447540822872', '441133910781', '17148307000');

foreach ($results as $result) {
    echo $result->detectedTelephoneNumber . ': ' . $result->liveStatus->value . "\n";
}
```

Per-Request Options
-------------------

[](#per-request-options)

```
use HlrLookup\DTO\LookupRequest;
use HlrLookup\Enum\SaveToCache;

$request = new LookupRequest(
    telephoneNumber: '447540822872',
    cacheDaysPrivate: 30,
    cacheDaysGlobal: 15,
    saveToCache: SaveToCache::YES,
    outputFormat: 'E164',
    inputFormat: 'GBR',         // ISO3 country code for local numbers
    getPortedDate: true,        // +1 credit
    getLandlineStatus: true,    // +1 credit (UK/Ireland only)
    usaStatus: true,            // +1 credit (USA mobile only)
);

$results = $hlr->hlr($request);
```

Working with Results
--------------------

[](#working-with-results)

```
$result = $results[0];

// Status
$result->liveStatus;              // LiveStatus enum: LIVE, DEAD, ABSENT_SUBSCRIBER, etc.
$result->telephoneNumberType;     // TelephoneNumberType enum: MOBILE, LANDLINE, VOIP, etc.
$result->isPorted;                // PortedStatus enum: YES, NO, UNKNOWN
$result->disposableNumber;        // DisposableStatus enum: YES, UNKNOWN

// Convenience methods
$result->isLive();                // bool
$result->isDead();                // bool
$result->isPorted();              // bool
$result->isDisposable();          // bool
$result->hasError();              // bool

// Network details
$result->originalNetworkDetails->name;       // "O2 (UK)"
$result->originalNetworkDetails->mccmnc;     // "23410"
$result->originalNetworkDetails->countryIso3; // "GBR"
$result->currentNetworkDetails->name;        // "EE"

// Other fields
$result->creditsSpent;            // float
$result->detectedTelephoneNumber; // "447540822872"
$result->formattedTelephoneNumber;// "+447540822872" (when output_format set)
$result->uuid;                    // unique identifier
$result->timestamp;               // "2022-10-07T13:06:15Z"
$result->portedDate;              // ISO 8601 date or "NOT_AVAILABLE"
```

Balance Check
-------------

[](#balance-check)

```
$balance = $hlr->lookups()->balance();
echo $balance->credits; // 150.5
```

Bulk Operations
---------------

[](#bulk-operations)

```
use HlrLookup\DTO\BatchArguments;

$bulk = $hlr->bulk();

// Create a batch
$batch = $bulk->create('my-numbers.csv');

// Upload numbers
$bulk->uploadNumbers($batch->id, ['447540822872', '441133910781']);

// Or upload a file
$bulk->uploadFile($batch->id, '/path/to/numbers.csv');

// Start processing
$bulk->start($batch->id);

// Check status
$batch = $bulk->get($batch->id);
echo $batch->status->value; // "PROCESSING", "COMPLETE", etc.

// Download results
$csv = $bulk->resultsCsv($batch->id);
$results = $bulk->resultsJson($batch->id); // LookupResult[]

// Schedule for later
$bulk->schedule($batch->id, new \DateTimeImmutable('2024-01-15T10:00:00Z'));

// Pause / delete
$bulk->pause($batch->id);
$bulk->delete($batch->id); // irreversible
```

Error Handling
--------------

[](#error-handling)

```
use HlrLookup\Exception\AuthenticationException;
use HlrLookup\Exception\BadRequestException;
use HlrLookup\Exception\RateLimitException;
use HlrLookup\Exception\ServerException;
use HlrLookup\Exception\ValidationException;

try {
    $results = $hlr->hlr('447540822872');
} catch (AuthenticationException $e) {
    // 401 - Invalid credentials
} catch (BadRequestException $e) {
    // 400 - Invalid parameters
} catch (RateLimitException $e) {
    // 429 - Too many requests, retry later
} catch (ServerException $e) {
    // 500 - Server error
} catch (ValidationException $e) {
    // Client-side validation (e.g., >80 numbers)
}
```

Optional Headers
----------------

[](#optional-headers)

```
$config = new Config(
    apiKey: 'your-key',
    apiSecret: 'your-secret',
    referenceId: 'my-ref-123',
    accountId: 'my-account',
);
```

Testing Suite
-------------

[](#testing-suite)

We provide a free testing suite at `testing.hlrlookup.com` so you can develop and test your integration without incurring any charges. The testing suite is pre-populated with example responses and is not connected to real telephone networks — no credits are spent.

```
$hlr = new HlrLookup(Config::testing());
$results = $hlr->hlr('441133910781');
```

`Config::testing()` is preconfigured with the testing suite URL and credentials, so you can start integrating immediately without needing an account.

### Test Numbers

[](#test-numbers)

The following numbers are available in the testing suite and return realistic responses:

NumberType447540822872MOBILE441133910781LANDLINE818000804085TOLL\_FREE448719429222PREMIUM6531522665VOIP447640123456PAGER7540BAD\_FORMATFor a complete list of test numbers, see the [testing documentation](https://www.hlrlookup.com/knowledge/testing).

### Running SDK Tests

[](#running-sdk-tests)

```
# Unit tests (mocked HTTP, no network access)
vendor/bin/phpunit --testsuite unit

# Integration tests (hits the free testing suite at testing.hlrlookup.com)
vendor/bin/phpunit --group integration
```

License
-------

[](#license)

MIT

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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 ~4 days

Total

2

Last Release

50d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d805b7ed843e1f94763d7f2e352d3bb39a51b4a580b95cb1024268afe7279dd3?d=identicon)[cata](/maintainers/cata)

---

Top Contributors

[![HLRLookup](https://avatars.githubusercontent.com/u/14197355?v=4)](https://github.com/HLRLookup "HLRLookup (7 commits)")

---

Tags

hlrhlr-lookuphlrlookupmnpnumber-validationphone-numberphpsdktelecomssmsphone-numberhlrmnphlr lookupnumber validationTelecomsnumber-portability

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[smsapi/php-client

SMSAPI API PHP Client

652.1M17](/packages/smsapi-php-client)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120220.7k1](/packages/ellaisys-aws-cognito)[seven.io/api

Official API Client for requesting the seven.io messaging Gateway.

1344.1k5](/packages/sevenio-api)[gr8shivam/laravel-sms-api

A modern, flexible Laravel package for integrating any SMS gateway with REST API support

10138.4k](/packages/gr8shivam-laravel-sms-api)[smsapi.pl/php-client

SMSAPI API PHP Client

6581.4k1](/packages/smsapipl-php-client)

PHPackages © 2026

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