uri-interfaces

by thephpleague

thephpleague / uri-interfaces

League URI Interfaces

213 Stars 1 Forks Last release: 9 months ago (2.1.0) MIT License 68 Commits 10 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Uri Interfaces

This package contains an interface to represents URI objects according to RFC 3986.

System Requirements

You need:

  • PHP >= 7.1.3 but the latest stable version of PHP is recommended

Install

$ composer require league/uri-interfaces

Documentation

League\Uri\Contract\UriInterface

The

UriInterface
interface models generic URIs as specified in RFC 3986. The interface provides methods for interacting with the various URI parts, which will obviate the need for repeated parsing of the URI. It also specifies:
  • a
    __toString()
    method for casting the modeled URI to its string representation.
  • a
    jsonSerialize()
    method to improve interoperability with WHATWG URL Living standard

Accessing URI properties

The

UriInterface
interface defines the following methods to access the URI string representation, its individual parts and components.

Modifying URI properties

The

Uri
interface defines the following modifying methods. these methods must be implemented such that they retain the internal state of the current instance and return an instance that contains the changed state.

Delimiter characters are not part of the URI component and must not be added to the modifying method submitted value. If present they will be treated as part of the URI component content.

These methods will trigger a

League\Uri\Contract\UriException
exception if the resulting URI is not valid. The validation is scheme dependent.

Relation with PSR-7

This interface exposes the same methods as

Psr\Http\Message\UriInterface
. But, differs on the following keys:

  • This interface does not require the
    http
    and
    https
    schemes to be supported.
  • Setter and Getter component methods, with the exception of the path component, accept and can return the
    null
    value.
  • If no scheme is present, you are not required to fallback to
    http
    and
    https
    schemes specific validation rules.

League\Uri\Contract\UriComponentInterface

The

UriComponentInterface
interface models generic URI components as specified in RFC 3986. The interface provides methods for interacting with an URI component, which will obviate the need for repeated parsing of the URI component. It also specifies a
__toString()
method for casting the modeled URI component to its string representation.

Accessing URI properties

The

UriComponentInterface
interface defines the following methods to access the URI component content.

Modifying URI properties

The

UriComponentInterface
interface defines the following modifying method. this method must be implemented such that it retains the internal state of the current instance and return an instance that contains the changed state.

UriComponentInterface extended interfaces

Because each URI component has specific needs most have specialized interface which all extends the

UriComponentInterface
interface. The following interfaces also exist:

  • League\Uri\Contract\AuthorityInterface
  • League\Uri\Contract\DataPathInterface
  • League\Uri\Contract\DomainHostInterface
  • League\Uri\Contract\FragmentInterface
  • League\Uri\Contract\UserInfoInterface
  • League\Uri\Contract\HostInterface
  • League\Uri\Contract\IpHostInterface
  • League\Uri\Contract\PathInterface
  • League\Uri\Contract\PortInterface
  • League\Uri\Contract\QueryInterface
  • League\Uri\Contract\SegmentedPathInterface

Contributing

Contributions are welcome and will be fully credited. Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.