PHP code example of fileinvite-org / laravel-url-signer
1. Go to this page and download the library: Download fileinvite-org/laravel-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/ */
fileinvite-org / laravel-url-signer example snippets
return [
/*
* The private key used to create the signature & sign the url.
*/
'private_key' => '-----BEGIN RSA PRIVATE KEY-----
MIIBOwIBAAJBAMLEGGPuPfopS53++75op5KaiDba4Lkcl7qjjTA8+W1Y1qzGGM2Z
2zwJ8Uk5alBu47fY63vUClVnGK0ieXviiEkCAwEAAQJAYXJnmagbzkxXDygCoNQP
86Ppvzhn83ZA3Br0i0wWqARJfHWnjiXgfJ+JOIOIngeGKGyd2Y9+6LhT+Ma79ByE
2QIhAOKwTPSCrVQrGj1shT87OuhAuXp5V3YmDGRqx+fVXoELAiEA2/MceDDmIuUn
LqOAfbPgbXOife/pFJjaGPrVcxIUmHsCIQCiyADqz+/RcgYst4HTjx/U6a2HMh1J
HTdm4HrekoyDUwIgCKYRm4RIuFyMYuAZAFhfXc5rOEqDvsSX5t2OIR035BsCIQCd
lf7pXxewNU9ky5sxHuKM4lWSy0BoDHrbyEw/Pigksg==
-----END RSA PRIVATE KEY-----',
/**
* The public key used to verify the signed url signature.
*/
'public_key' => '-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMLEGGPuPfopS53++75op5KaiDba4Lkc
l7qjjTA8+W1Y1qzGGM2Z2zwJ8Uk5alBu47fY63vUClVnGK0ieXviiEkCAwEAAQ==
-----END PUBLIC KEY-----',
/*
* The default expiration time of a URL in minutes.
*/
'default_expiration' => 60,
/*
* These strings are used a parameter names in a signed url.
*/
'parameters' => [
'expires' => 'expires',
'signature' => 'signature',
],
];
//the generated URL will be valid for 5 minutes.
UrlSigner::sign('https://myapp.com/protected-route', 5);
//This URL will be valid up until 2 days from the moment it was generated.
UrlSigner::sign('https://myapp.com/protected-route', Carbon::now()->addDays(2) );