IRI handling for PHP

Maintainers

👁 zozlak

Package info

github.com/sweetrdf/IRI

Homepage

pkg:composer/sweetrdf/iri

Statistics

Installs: 4 242

Dependents: 2

Suggesters: 0

Stars: 0

1.2.1 2026-03-19 13:47 UTC

Requires

  • php: >=8.1.0

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

MIT 31246f99f7cf0f9b38f0f83ada28e1d019054bb8

urliriuriURN

This package is auto-updated.

Last update: 2026-05-19 14:13:47 UTC


README

Note

This is a fork of the Original IRI class written by Markus Lanthaler. I maintain it in my spare time to keep it alive and usable on the latest PHP versions. Code is more or less maintained but not developed any further. If you wanna participate, feel free to open a pull request!

This is a simple PHP class to ease IRI handling. Currently it just supports parsing of IRIs and relative IRI resolution.

With more than 800 tests, this class is extensively tested.

Installation

The easiest way to use IRI is to integrate it as a dependency in your project's composer.json file:

{
 "require": {
 "sweetrdf/iri": "^1"
 }
}

or run:

composer install sweetrdf/iri

Of course you can also just download an archive from Github.

Compatible with original ml/iri

This library is intented to be a drop-in replacement for the original ml/iri library. However, the IRI class was adapted to be more type safe:

  • Added declare(strict_types=1); to the file
  • Added explicit type information to each class property
  • Added explicit return value types to each class method

IRI does not throw an InvalidArgumentException anymore if an invalid value was given in the constructor! In this case PHP itself will complain.

Credits

Most test cases come either directly from the URI specification, from Graham Klyne's, or Tim Berners-Lee's test suite.