Download the PHP package loophp/path-hasher without Composer
On this page you can find all versions of the php package loophp/path-hasher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download loophp/path-hasher
More information about loophp/path-hasher
Files in loophp/path-hasher
Package path-hasher
Short Description Library to serialize a filesystem path
License EUPL-1.2
Homepage https://github.com/loophp/path-hasher
Informations about the package path-hasher
![Latest Stable Version][latest stable version] ![GitHub stars][github stars] ![Total Downloads][total downloads] ![GitHub Workflow Status][github workflow status] ![Type Coverage][type coverage] ![License][license] ![Donate!][donate github]
Path Hasher
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 ecosystem. See chapter 5 of Eelco Dolstra’s PhD thesis for technical details about the NAR format.
- SWHID: Computes [SWHID] (Software Heritage persistent identifiers) for files, directories, and symlinks, following the Software Heritage 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
composer require loophp/path-hasher
Usage
NAR Example
Methods available are:
hash: Compute the SRI hash of a given path.extract: Extract a NAR archive to a specified directory.stream: Get a stream generator of the NAR archive.computeHashes: Compute hashes of the NAR archive with different algorithms.
SWHID Example
Note:
- The SWHID implementation only supports the
"cnt"(content) and"dir"(directory) object types, which correspond to files, symlinks, and directories on the filesystem. - Higher-level SWHID types (
"rel"for release,"rev"for revision,"snp"for snapshot) are not supported by this implementation yet.
Methods available are:
hash: Compute the SWHID of a given path.stream: Get a stream generator of the SWHID archive.
Code quality, tests, benchmarks
Every time changes are introduced into the library, Github runs the tests.
The library has tests written with PHPUnit. Feel free to check them out in
the tests directory.
Before each commit, some inspections are executed with GrumPHP; run
composer grumphp to check manually.
Contributing
Feel free to contribute by sending pull requests. We are a usually very responsive team and we will help you going through your pull request from the beginning to the end.
For some reasons, if you can't contribute to the code and willing to help, sponsoring is a good, sound and safe way to show us some gratitude for the hours we invested in this package.
Sponsor me on Github and/or any of the contributors.
[latest stable version]: https://img.shields.io/packagist/v/loophp/path-hasher.svg?style=flat-square [github stars]: https://img.shields.io/github/stars/loophp/path-hasher.svg?style=flat-square [total downloads]: https://img.shields.io/packagist/dt/loophp/path-hasher.svg?style=flat-square [github workflow status]: https://img.shields.io/github/actions/workflow/status/loophp/path-hasher/tests.yml?branch=main&style=flat-square [type coverage]: https://img.shields.io/badge/dynamic/json?style=flat-square&color=color&label=Type%20coverage&query=message&url=https%3A%2F%2Fshepherd.dev%2Fgithub%2Floophp%2Fpath-hasher%2Fcoverage [license]: https://img.shields.io/packagist/l/loophp/path-hasher.svg?style=flat-square [donate github]: https://img.shields.io/badge/Sponsor-Github-brightgreen.svg?style=flat-square
[SWHID]: https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html