outlet-key is a PHP library for anything that counts sources, corroborates a story or deduplicates a feed. It tells you which newsroom owns a news URL and which article it is. The code is at https://github.com/IndianOpinion/outlet-key, under the MIT licence. Version v0.1.0 was released on 14 November 2026.
The host string is the wrong answer in both directions. A mobile host, a regional host and a legacy host of one outlet are one newsroom, but counted by host they are three, so a single-source story looks corroborated three times. Two newsrooms that sit under one parent portal domain are two, but counted by registrable domain they are one, so a story that really is corroborated looks single-source.
Articles have the same problem. One article arrives with and without a trailing slash, under an AMP path, with a tracking query, and wrapped in a Google AMP cache URL. Keyed by raw URL that is six articles, ingested six times.
Without a shared library each consumer writes its own prefix strip. The strips drift apart, one outlet ends up with two identities, and anything keyed on outlet forks silently.
sameOutlet() and sameArticle().explain() and a CLI --explain flag, and gives sha256 hashes of keys for storage.The empty string is the key for “unknown”, and it is never an outlet. The outlet key is built in order:
The article key is the outlet key, then the normalised path, then the kept query. On a slug path only id parameters survive. On a script path every non-tracking parameter survives. Outlets with an id rule key as outlet/a/<id>, and other outlets as outlet/s/<slug key>.
The main classes are OutletResolver, ArticleKeyer, OutletMap (immutable and validated), PublicSuffixList, Trace and KeyHash. The map is a JSON file compiled into hash sets, so there is no I/O and no linear scan after load. Overrides use your own entries:
$map = OutletMap::bundled()->withOverrides([
'aliases' => ['example-mirror.com' => 'example.com'],
]);
$resolver = new OutletResolver($map, ['www.my-site.example']);
$keyer = new ArticleKeyer($resolver);
$key = $resolver->outletKey($url);
if ($key !== '' && !$resolver->isAggregator($key) && !$resolver->isOwnOutlet($key)) {
// a newsroom that can corroborate a story
}
On the command line, vendor/bin/outlet-key --explain <url> shows which step decided. The repo’s own benchmark script, run on generated URLs rather than real traffic, reports about 9 microseconds for an outlet key and about 25 for an article key on PHP 8.3, one core, over 100,000 mixed URLs.
InputTooLongException from both key functions.InvalidMapException and cannot quietly change keys.ext-intl and ext-mbstring are not used, and a test runs the fixtures under php -n and compares the output.caseInsensitivePaths, because lowercasing can merge distinct articles. A missed duplicate costs one item. A false merge loses an article.https:, keyed as an outlet named https. A lone scheme is now unparseable./c/S/..., read S as the host. The s/ marker now matches in either case.The review also fuzzed 200,000 random structured inputs, which raised nothing except the length exception, and checked the built-in Punycode encoder against ext-intl on 20,000 random labels.
Test status: this is v0.1.0. 177 PHPUnit tests (965 assertions) pass, with PHPStan level 8 and PSR-12 checks clean. CI has not yet run on GitHub, so PHP 8.1 and 8.2 were not run. It has been tested on fixtures and fuzzed inputs, not on a live feed.
Requires PHP 8.1 or later and no runtime dependencies.
The package is not on Packagist yet, so first add a Composer vcs repository entry for https://github.com/IndianOpinion/outlet-key.
composer require indianopinion/outlet-key
Without Composer, clone the repository and require its bootstrap.php, which registers an autoloader for the IndianOpinion\OutletKey namespace.