shahadh/laravel-temporary-links
Composer 安装命令:
composer require shahadh/laravel-temporary-links
包简介
Generate temporary, expiring access links for Laravel applications
README 文档
README
A Laravel package for generating temporary, expiring access links for users to view/download content securely.
Features
- ✅ Time-Limited Links – Links expire after a set time (e.g., 24 hours)
- ✅ One-Time Use Links – Restrict access to a single open/download
- ✅ IP & Device Restrictions – Limit access to specific IPs or devices
- ✅ Webhook Integration – Get notified when a link is accessed
Installation
You can install the package via composer:
composer require shahadh/laravel-temporary-links
Publish the migrations and config:
php artisan vendor:publish --tag="temporary-links-migrations" php artisan vendor:publish --tag="temporary-links-config"
Run the migrations:
php artisan migrate
Usage
Basic Usage
// Add the trait to your model use Shahadh\TemporaryLinks\Traits\HasTemporaryLinks; class Document extends Model { use HasTemporaryLinks; } // Create a temporary link $document = Document::find(1); $link = $document->createTemporaryLink(); // Get the URL $url = $link->getUrl();
Link Options
// Create a link that expires in 1 hour $link = $document->createExpiringTemporaryLink(60); // Create a single-use link $link = $document->createSingleUseTemporaryLink(); // Create a link with IP restriction $link = $document->createTemporaryLink([ 'restrict_ip' => $request->ip() ]); // Create a link with device restriction $link = $document->createTemporaryLink([ 'restrict_device' => true ]); // Create a link with custom path $link = $document->createTemporaryLinkForPath('/downloads/secret-file.pdf');
Handling Access
By default, accessing a link will redirect to the model or path. You can customize this behavior by adding a handleTemporaryAccess method to your model:
public function handleTemporaryAccess($link, $request) { // Custom access logic here return Storage::download($this->file_path); }
Webhook Integration
Configure webhooks in the config file to receive notifications when links are accessed or expire.
Configuration
See the config/temporary-links.php file for all configuration options.
License
The MIT License (MIT). Please see License File for more information.
shahadh/laravel-temporary-links 适用场景与选型建议
shahadh/laravel-temporary-links 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 65 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 shahadh/laravel-temporary-links 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shahadh/laravel-temporary-links 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 65
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-09