After a period of private review, the uri-interop/interface package is now open for public review.

Uri-Interop publishes a standard set of interoperable URI interfaces for PHP 8.4+. It reflects, refines, and reconciles the common practices identified within several pre-existing projects.

The package defines separate interfaces to afford reading and modifying URI component values:

  • Uri StringableComponents affords reading of the URI component values and recomposing them into a string.
  • MutableUri MutableComponents extends Uri StringableComponents to afford direct modification of component values.
  • ImmutableUri ImmutableComponents extends Uri StringableComponents to afford immutable modification of component values.

Uri-Interop defines factory and parser interfaces:

  • UriFactory UriEncodedFactory affords creating a new URI instance from URI component values.
  • UriParser UriEncodedParser affords creating a new URI instance from a URI string.

Uri-Interop defines these marker interfaces to codify expectations around RFC compliance:

  • Rfc3986Compliant UriEncoded marks any of the other interfaces to indicate RFC 3986 compliance.
  • Rfc3987Compliant IriEncoded marks any of the other interfaces to indicate RFC 3987 compliance.

Finally, Uri-Interop defines an interface of PHPStan type aliases, UriTypeAliases, to aid static analysis.

If you use URI objects (who doesn't!) and are interested an interoperable set of interfaces, please offer your comments and criticism as issues or pull requests out at Github.


UPDATE (Mon 17 Mar 2025): Based on review, some of the interface names have changed since the initial announcement, though their purpose remains the same.

Are you stuck with a legacy PHP application? You should buy my book because it gives you a step-by-step guide to improving you codebase, all while keeping it running the whole time.