PHPackages                             tacman/nitf-parser - 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. tacman/nitf-parser

ActiveLibrary

tacman/nitf-parser
==================

Parse NITF (News Industry Text Format) XML documents into a flat structure for search indexing

1.0.1(yesterday)01↓100%MITPHPPHP ^8.4

Since Apr 6Pushed yesterdayCompare

[ Source](https://github.com/tacman/nitf-parser)[ Packagist](https://packagist.org/packages/tacman/nitf-parser)[ RSS](/packages/tacman-nitf-parser/feed)WikiDiscussions main Synced today

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

NITF Parser
===========

[](#nitf-parser)

A PHP library for parsing NITF (News Industry Text Format) XML documents into a flat, searchable structure optimized for Meilisearch and similar full-text search engines.

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

[](#installation)

```
composer require tacman/ntif-parser
```

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

[](#requirements)

- PHP 8.4+

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

[](#quick-start)

```
use Tacman\NTF\NTF;

// Parse from file
$ntf = NTF::fromFile('article.xml');

// Or from XML string
$ntf = NTF::fromXml($xmlString);

// Or from a zip archive containing multiple NITF files
foreach (NTF::fromZip('articles.zip') as $ntf) {
    echo $ntf->headline;
}

// Get a flat array ready for indexing
$searchable = $ntf->toSearchable();
```

Available Fields
----------------

[](#available-fields)

The `NTF` class provides these public properties:

PropertyTypeDescription`$id``string`Document ID (from `doc-id/@id-string`)`$headline``string`Main headline (from `hl1`)`$subhead``string`Sub-headline (from `hl2`)`$byline``string`Author byline`$summary``string`Article summary/abstract`$body``string`Full body text (all `` elements joined)`$keywords``string[]`Keywords from key-list`$categories``array`Classifications as `['type' => '...', 'value' => '...']``$images``array`Media references with `source`, `name`, `mimeType``$publishedAt``?DateTime`Publication date`$modifiedAt``?DateTime`Last modification date`$section``?string`Publication section`$type``?string`Publication typeMeilisearch Integration
-----------------------

[](#meilisearch-integration)

The `toSearchable()` method returns a flat array ready for direct indexing:

```
$ntf = NTF::fromFile('article.xml');
$searchable = $ntf->toSearchable();

// Index directly into Meilisearch
$client->index('articles')->addDocuments([$searchable]);
```

The searchable array includes all fields with:

- `publishedAt` and `modifiedAt` as ISO 8601 strings
- `keywords` as an array
- `categories` and `images` as JSON arrays

Zip File Processing
-------------------

[](#zip-file-processing)

Process large archives efficiently using the generator:

```
// Iterate through all NITF files in a zip
$count = 0;
foreach (NTF::fromZip('archive.zip') as $ntf) {
    $count++;
    // Process each document
}

// Or get all as an array
$all = NTF::allFromZip('archive.zip');
```

The zip parser:

- Only processes `.xml` files
- Skips invalid XML files silently
- Uses a generator for memory efficiency

Example
-------

[](#example)

Given a NITF XML file:

```

        Big Game Today
        Preview and analysis

      By John Smith

      First paragraph of the article...
      Second paragraph...

```

You get:

```
$ntf->id;           // "abc123"
$ntf->headline;    // "Big Game Today"
$ntf->subhead;     // "Preview and analysis"
$ntf->byline;      // "By John Smith"
$ntf->body;        // "First paragraph...\n\nSecond paragraph..."
$ntf->keywords;     // ["#news", "#sports"]
$ntf->section;     // "news/sports"
$ntf->publishedAt; // DateTime object
```

Testing
-------

[](#testing)

```
./vendor/bin/phpunit
```

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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

Total

2

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/21b39551f92ed4143772c622f9e571589c5a72c96ab3c53fe67489ce0d83e806?d=identicon)[tacman1123](/maintainers/tacman1123)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tacman-nitf-parser/health.svg)

```
[![Health](https://phpackages.com/badges/tacman-nitf-parser/health.svg)](https://phpackages.com/packages/tacman-nitf-parser)
```

PHPackages © 2026

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