Note: This package is still in early development stages
This PHP/Laravel package will help you to easily generate links which are secured by nginx's ngx_http_secure_link_module
| Laravel | nginx_secure_link | PHP |
|---|---|---|
| 5.x | 1.0.x | >= 5.3 |
Through command line:
composer require m0nsky/nginx_secure_linkThrough composer.json:
{
"require": {
"m0nsky/nginx_secure_link": "1.0.*"
}
}
Including the secure link class
use m0nsky\NginxSecureLink\NginxSecureLink;Publish configuration
php artisan vendor:publish --provider="m0nsky\NginxSecureLink\Providers\NginxSecureLinkServiceProvider"Update configuration
return [
'base_path' => '/var/www/path/to/files/',
'base_url' => 'https://example.com/url/to/files/',
'secret' => 'secret',
'ttl' => 60, // (seconds)
];Instantiate class
Note: If no parameters are specified, the wrapper will use the settings as specified in your nginx_secure_link.php config
$nginxSecureLink = new NginxSecureLink();or
$nginxSecureLink = new NginxSecureLink('/path/to/files/', 'https://example.com/url/to/files/', 60, 'secret');Generate file url
$url = $nginxSecureLink->getUrl('archive.zip');Which will return a string in the following format
https://example.com/url/to/files/archive.zip?md5=AUEnXC7T-Tfv9WLsWbf-mw&expires=1483228740
