tleckie / url-signer
Create secured URLs with a limited lifetime in php
Fund package maintenance!
teodoroleckie
www.paypal.com/donate?business=ZHYA2MTGA4884¤cy_code=USD
Requires
- php: ^8
- httpsoft/http-message: ^1.0
- psr/http-factory: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: v3.0.0-beta.2
- infection/infection: ^0.21.5
- phpunit/phpunit: ^9.5
README
Create secured URLs with a limited lifetime in php
Installation
You can install the package via composer:
composer require tleckie/url-signer
Usage
<?php use Tleckie\UrlSigner\Exception\UnsignedException; use Tleckie\UrlSigner\Exception\ExpiredUriException; use Tleckie\UrlSigner\Signer; // sign with expiration $signer = new Signer('password', 'signature','ttl',3600); $signed = $signer->sign('https://www.domain.com/path/?query=value'); // https://www.domain.com/path/?query=value&ttl=1619446592&signature=b42cb0868c6c46aad10d2a5f6e3c6503cd6b9668 try{ $signer->validate($signed); }catch(ExpiredUriException $exception){ // handle expired uri }catch(UnsignedException $exception){ // Decrypt failed } // sign without expiration $signer = new Signer('password', 'signature'); $signed = $signer->sign('https://www.domain.com/path/?query=value'); // https://www.domain.com/path/?query=value&signature=e39fe2feea843712dc2b3fa069a50c6965594f5b