<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dreamonkey / laravel-cloudfront-url-signer example snippets
// With Facade
CloudFrontUrlSigner::sign('https://myapp.com/resource', 30);
// With helper
sign('https://myapp.com/resource', 30);
return [
/*
* The default expiration time of a URL in days.
*/
'default_expiration_time_in_days' => 1,
/*
* The private key used to sign all URLs.
*/
'private_key_path' => storage_path(env('CLOUDFRONT_PRIVATE_KEY_PATH', 'trusted-signer.pem')),
/*
* Identifies the CloudFront key pair associated
* to the trusted signer which validates signed URLs.
*/
'key_pair_id' => env('CLOUDFRONT_KEY_PAIR_ID', ''),
/*
* CloudFront API version, by default it uses the latest available.
*/
'version' => env('CLOUDFRONT_API_VERSION', 'latest'),
];
// The generated URL will be valid for 5 days.
CloudFrontUrlSigner::sign('https://myapp.com/resource', 5);
// This URL will be valid up until 2 hours from the moment it was generated.
CloudFrontUrlSigner::sign('https://myapp.com/resource', Carbon\Carbon::now()->addHours(2) );