PHPackages                             loophp/path-hasher - 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. loophp/path-hasher

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

loophp/path-hasher
==================

Library to serialize a filesystem path

1.1.2(6mo ago)318[2 PRs](https://github.com/loophp/path-hasher/pulls)EUPL-1.2PHPPHP ^8.1CI passing

Since Oct 24Pushed 1mo agoCompare

[ Source](https://github.com/loophp/path-hasher)[ Packagist](https://packagist.org/packages/loophp/path-hasher)[ Docs](https://github.com/loophp/path-hasher)[ GitHub Sponsors](https://github.com/drupol)[ RSS](/packages/loophp-path-hasher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (6)Versions (13)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/917d835a530c574d0c6e723fb783a93ef11db98b43ffed577f3041ae016c0a94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f6f7068702f706174682d6861736865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/loophp/path-hasher)[![GitHub stars](https://camo.githubusercontent.com/b7548c0b74f2a8725ab805f05643d580be8ea948f04edda2fb5b8fdca254f571/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6c6f6f7068702f706174682d6861736865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/loophp/path-hasher) [![Total Downloads](https://camo.githubusercontent.com/c868efda491240d11d16a828b873fd1cd613cae26c2d54af87068d015d1cde32/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f6f7068702f706174682d6861736865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/loophp/path-hasher)[![GitHub Workflow Status](https://camo.githubusercontent.com/d227794e702dba8a97832f8378c6c3560ae9a3f356e815d9e4ac36af2399ceb5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c6f6f7068702f706174682d6861736865722f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/loophp/path-hasher/actions)[![Type Coverage](https://camo.githubusercontent.com/736a3754c2c842fdb77e2a870916501e02677f23cc8793feafe8e3a80991ebb2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f64796e616d69632f6a736f6e3f7374796c653d666c61742d73717561726526636f6c6f723d636f6c6f72266c6162656c3d54797065253230636f7665726167652671756572793d6d6573736167652675726c3d687474707325334125324625324673686570686572642e6465762532466769746875622532466c6f6f706870253246706174682d686173686572253246636f766572616765)](https://shepherd.dev/github/loophp/path-hasher) [![License](https://camo.githubusercontent.com/a73c15b485f95f6997d4b9bd2ed51056184b80acb0d8d122d8de1f5ecdb24be9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6f6f7068702f706174682d6861736865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/loophp/path-hasher)[![Donate!](https://camo.githubusercontent.com/a71f45de7e408be2477113d166e9ee94c90bbf814a1373fd154aa5b6652302de/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d4769746875622d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/sponsors/drupol)

Path Hasher
===========

[](#path-hasher)

Description
-----------

[](#description)

Path Hasher is a PHP library for deterministically hashing filesystem objects (files, directories, and symlinks) in a reproducible and platform-independent way.

The library provides two implementations:

- **NAR**: Serializes and hashes paths using the Nix ARchive (NAR) format, as used in the [Nix](https://nixos.org/) ecosystem. See chapter 5 of Eelco Dolstra’s [PhD thesis](https://edolstra.github.io/pubs/phd-thesis.pdf) for technical details about the NAR format.
- **SWHID**: Computes [SWHID](https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html) (Software Heritage persistent identifiers) for files, directories, and symlinks, following the [Software Heritage](https://softwareheritage.org/)specification.

With this library, you can:

- Hash any filesystem path in a deterministic way (NAR, SWHID).
- Extract or reconstruct filesystem trees from NAR archives (NAR)

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

[](#installation)

`composer require loophp/path-hasher`

Usage
-----

[](#usage)

### NAR Example

[](#nar-example)

Details```
