Download the PHP package zenstruck/uri without Composer
On this page you can find all versions of the php package zenstruck/uri. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zenstruck/uri
More information about zenstruck/uri
Files in zenstruck/uri
Informations about the package uri
zenstruck/uri
Object-oriented wrapper/manipulator for parse_url
with the following features:
- Read URI parts as objects (
Scheme
,Host
,Path
,Query
), each with their own set of features. - Manipulate URI parts or build URI's using a fluent builder API.
- Sign and verify URI's and make them temporary and/or single-use.
- Mailto object to help with reading/manipulating
mailto:
URIs. - RFC 6570) support.
- PSR-13 Link implementation/bridge.
- Twig Extension.
This library is meant as a wrapper for PHP's parse_url
function only and does not
conform to any URI-related PSR or RFC. If you need this,
league/uri would be a better choice.
Installation
Parsing/Reading URIs
Manipulating URIs
Note:
Zenstruck\Uri\ParsedUri
is an immutable object so any manipulations results in a new instance.
Signed URIs
Note:
symfony/http-kernel
is required to sign and verify URIscomposer require symfony/http-kernel
.
You can sign a URI:
Temporary URIs
Make an expiring signed URI:
Single-Use URIs
These URIs are generated with a token that should change once the URI has been used.
Note: It is up to you to determine this token and depends on the context. This value MUST change after the token is successfully used, else it will still be valid.
Note: The URL is first hashed with this token, then hashed again with secret to ensure it hasn't been tampered with.
Signed URI Builder
Calling Zenstruck\Uri\ParsedUri::sign()
returns a Zenstruck\Uri\Signed\Builder
object that can be used to
create single-use and temporary URIs.
Note:
Zenstruck\Uri\Signed\Builder
is immutable objects so any manipulations results in a new instance.
Verification
To verify a signed URI, create an instance of Zenstruck\Uri\ParsedUri
and call isVerified()
to
get true/false or verify()
to throw specific exceptions:
Single-Use Verification
For validating single-use URIs, you need to pass a token to the verify methods:
SignedUri
Zenstruck\Uri\Signed\Builder::create()
and Zenstruck\Uri\ParsedUri::verify()
both return a
Zenstruck\Uri\SignedUri
object that implements Zenstruck\Uri
and has some helpful methods.
Note:
Zenstruck\Uri\SignedUri
is always considered verified and cannot be manipulated.
UriLink
A PSR-13 Link implementation is provided with:
Zenstruck\Uri\Link\UriLink
(implements bothPsr\Link\LinkInterface
andZenstruck\Uri
).Zenstruck\Uri\Link\UriLinkProvider
(implementsPsr\Link\LinkProviderInterface
and providesZenstruck\Uri\Link\UriLink
's).
TemplateUri
Note:
rize/uri-template
is required to useTemplateUri
-composer require rize/uri-template
.
Zenstruck\Uri\TemplateUri
allows creating/manipulating RFC 6570
uri templates and implements Zenstruck\Uri
.
Mailto
Note:
Zenstruck\Uri\Mailto
is an immutable object so any manipulations results in a new instance.
Twig Extension
A twig extension providing uri
, mailto
filters and
functions is included.