Download the PHP package code4nix/uri-signer without Composer
On this page you can find all versions of the php package code4nix/uri-signer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download code4nix/uri-signer
More information about code4nix/uri-signer
Files in code4nix/uri-signer
Package uri-signer
Short Description uri signer with expiration option
License GPL-3.0-or-later
Informations about the package uri-signer
URI Signer with expiration support for Symfony framework
Create and check signed URIs with expiration time support. This bundle is a further development of Symfony's URI Signer.
Installation
Usage
Create a signed URI
To create a signed URI with an expiration time of 1 day (default), you can use $this->uriSigner->sign($strUri)
.
You can add a second parameter $intExpires
to add a custom expiration time. E.g. call $this->uriSigner->sign($strUri, 600)
to get a URI with an expiration time of 10 minutes.
Check the signed URI/request
To check the URI you can use $this->uriSigner->check($strUri)
.
Instead of building a URI you can call $this->uriSigner->checkRequest($request)
method
and pass a Symfony\Component\HttpFoundation\Request
object to check the signature of its related URI. Both methods return boolean true
if the URI passes validation, or boolean false
if the URI is invalid or expired.
Error handling
Alternatively you can run the check()
or checkRequest()
methods with a second optional boolean parameter $this->uriSigner->check($strUri, true)
or $this->uriSigner->checkRequest($request, true)
, which will raise exceptions if a URI cannot be verified (e.g. has been tampered, has expired or is a malformed URI).
MalformedUriException
InvalidSignatureException
ExpiredLinkException
Usage in your controller:
Configuration:
The default expiration and the parameter are configurable: