PHPackages                             dormilich/apnic - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. dormilich/apnic

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

dormilich/apnic
===============

A PHP library to read/write APNIC whois object data.

1.3.0(5y ago)077LGPL-2.1PHPPHP ^7.0CI failing

Since Feb 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Dormilich/apnic)[ Packagist](https://packagist.org/packages/dormilich/apnic)[ RSS](/packages/dormilich-apnic/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

APNIC data objects
==================

[](#apnic-data-objects)

A PHP library to read, write, and validate APNIC RPSL objects.

Reading Objects
---------------

[](#reading-objects)

The utility class `WhoisParser` can read the output retrieved from the `whois` command and turn it into RPSL objects.

```
use Dormilich\APNIC\Utilities\WhoisParser;

$reader = new WhoisParser;

// of course you can use any CLI processor you like
$whois = `whois '192.186.2.0 - 192.186.2.8' -h whois.apnic.net`; # using GNU whois here

try {
  if ($net = $reader->parse($whois)) {
    // do something with the Inetnum object ...
  }
}
catch (Exception $e) {
  // ... or show any problems you got while parsing
  echo $e;
}
```

If you are certain which object to expect, you can feed it to the parser. This will always get you an object back.

```
use Dormilich\APNIC\Utilities\WhoisParser;
use Dormilich\APNIC\RPSL\Inetnum;

$reader = new WhoisParser;

$whois = `whois '192.186.2.0 - 192.186.2.8' -h whois.apnic.net -rxB`;

try {
  // unlike the first example, $net will always be an RPSL object
  $net = $reader->parse($whois, new Inetnum(null));

  if (!$net->isValid()) {
    // something is left out
  }

  // do something with the Inetnum object ...
}
catch (Exception $e) {
  echo $e;
}
```

If you want to read all RPSL objects from the output, that’s also possible. The only downside is that you don’t know beforehand what’s all inside …

```
use Dormilich\APNIC\Utilities\WhoisParser;

$reader = new WhoisParser;

$whois = `whois '192.186.2.0 - 192.186.2.8' -h whois.apnic.net -rxB`;

try {
  $data = $reader->parseAll($whois);

  $net = $data['192.186.2.0 - 192.186.2.8'];
  $admin1 = $data[ $net['admin-c'][0] ];

  // ...
}
catch (Exception $e) {
  echo $e;
}
```

Working with Objects
--------------------

[](#working-with-objects)

The RPSL objects allow to conveniently edit RPSL data.

```
use Dormilich\APNIC\RPSL\Person;

$person = new Person;

// set a value to an attribute
$person['person'] = 'John Doe';
$person->set('source', 'APNIC');

// add values to a multiple attribute
$person
  ->add('address', 'infinity drive 1')
  ->add('address', 'anytown')
;

// get a value from an attribute
echo $person['person']; // John Doe
echo $person->get('source'); // APNIC
$address = $person->get('address'); // ['infinity drive 1', 'anytown']

// delete values
unset($person['source']);
var_dump( $person->get('source') ); // NULL
```

But you’re not limited to primitive values, attributes that accept handles allow the appropriate object as input. And for the most common attributes, these even get validated.

```
// you can even pass RPSL objects to appropriate attributes
$maint = ... // get that object from whois
$obj['mnt-by'] = $maint;

// common attributes that contain references validate any passed RPSL object
// e.g. this throws an exception since tech contacts can only be Person or Role handles
$obj->add('tech-c', $maint);
```

Templates … for that the RPSL objects and their attributes are iterable.

Writing Objects
---------------

[](#writing-objects)

'Writing' may be a bit of an exaggeration. Essentially, printing an object creates its textual representation that you can use in an email update.

```
use Dormilich\APNIC\Utilities\WhoisParser;

$reader = new WhoisParser;

$whois = `whois JD12-AP -h whois.apnic.net -rB`;

try {
  if ($john = $reader->parse($whois)) {
    $john
      ->add('phone', '+1 234 567 8901')
      ->add('e-mail', 'john.doe@example.com')
    ;
    $body = $john . 'password: ' . $my_apnic_password;
    // please use a proper email client!
    mail('auto-dbm@apnic.net', $john->getHandle(), $body, ...);
  }
}
catch (Exception $e) {
  echo $e;
}
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Recently: every ~371 days

Total

6

Last Release

1926d ago

PHP version history (2 changes)1.0.0PHP ^5.6 || ^7.0

1.2.0PHP ^7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/392135?v=4)[Bertold von Dormilich](/maintainers/Dormilich)[@Dormilich](https://github.com/Dormilich)

---

Top Contributors

[![Dormilich](https://avatars.githubusercontent.com/u/392135?v=4)](https://github.com/Dormilich "Dormilich (54 commits)")

---

Tags

composer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dormilich-apnic/health.svg)

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

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19037.7M41](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9642.0k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

46143.1k6](/packages/jstewmc-rtf)[moonshine/layouts-field

Field for repeating groups of fields for MoonShine

107.9k](/packages/moonshine-layouts-field)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

112.9k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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