1. Go to this page and download the library: Download spatie/url-signer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
spatie / url-signer example snippets
$urlSigner = new Sha256UrlSigner('randomkey');
$urlSigner->sign('https://myapp.com', 30);
// => The generated url will be valid for 30 seconds
// returns `true` if valid, `false` if not
$urlSigner->validate('https://myapp.com/?expires=xxxx&signature=xxxx');
use Spatie\UrlSigner\Sha256UrlSigner;
$urlSigner = new Sha256UrlSigner('mysecretkey');
$expirationDate = (new DateTime())->modify('10 days');
$urlSigner->sign('https://myapp.com', $expirationDate);
// => The generated url will be valid for 10 days
$urlSigner->sign('https://myapp.com', 30);
// => The generated URL will be valid for 30 seconds