grazulex/laravel-sharelink 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

grazulex/laravel-sharelink

Composer 安装命令:

composer require grazulex/laravel-sharelink

包简介

Generate, manage, and secure temporary share links for files, routes, and model previews.

README 文档

README

Laravel ShareLink

Generate, manage, and secure temporary share links for files, routes, and models

A powerful Laravel package for creating secure, time-limited sharing capabilities with comprehensive audit trails

Latest Version Total Downloads License PHP Version Laravel Version Tests Code Style

🚀 Overview

Laravel ShareLink is a comprehensive package for generating secure, time-limited sharing capabilities in your Laravel applications. Perfect for sharing files, creating temporary access to routes, or providing time-limited previews of model data with complete audit trails and advanced security features.

✨ Key Features

  • 🔗 Multiple Resource Types - Share files, routes, and model previews seamlessly
  • Time-Limited Access - Set expiration dates and usage limits
  • 🔒 Password Protection - Optional password gates for enhanced security
  • 🚫 Rate Limiting - Per-token rate limiting to prevent abuse
  • 🌐 IP Filtering - Allow/deny specific IP addresses or CIDR ranges
  • 🔏 Signed URLs - Optional Laravel signed route integration
  • 🔥 Burn After Reading - One-time access links that self-destruct
  • 📊 Comprehensive Auditing - Track access patterns, IPs, and timestamps
  • 🛡️ Advanced Security - Password throttling, brute force protection
  • 🎯 Flexible Delivery - Support for X-Sendfile, X-Accel-Redirect, and streaming
  • 📋 Management API - Revoke and extend links programmatically
  • 🎨 CLI Commands - Full Artisan command support
  • 📈 Observability - Built-in logging and metrics integration
  • 🧪 Test-Friendly - Comprehensive test coverage with easy mocking

📦 Installation

Install the package via Composer:

composer require grazulex/laravel-sharelink

Publish and run the migrations:

php artisan vendor:publish --tag="sharelink-migrations"
php artisan migrate

Optionally, publish the configuration file:

php artisan vendor:publish --tag="sharelink-config"

💡 Auto-Discovery: The service provider will be automatically registered thanks to Laravel's package auto-discovery.

⚡ Quick Start

🚀 Basic Usage

use Grazulex\ShareLink\Facades\ShareLink;

// Share a file with expiration
$link = ShareLink::create('/path/to/document.pdf')
    ->expiresIn(60) // 60 minutes
    ->maxClicks(5)
    ->withPassword('secret123')
    ->generate();

echo $link->url; // https://yourapp.com/share/abc123xyz

📁 File Sharing

// Share a local file
$link = ShareLink::create('/storage/documents/report.pdf')
    ->expiresIn(1440) // 24 hours
    ->maxClicks(10)
    ->generate();

// Share via Laravel Storage
$link = ShareLink::create('s3://bucket/private/document.pdf')
    ->expiresIn(60)
    ->withPassword('secure')
    ->generate();

🌐 Route Sharing

// Share a named route with parameters
$link = ShareLink::create([
    'type' => 'route',
    'route' => 'user.profile',
    'parameters' => ['user' => 123]
])
->expiresIn(120)
->generate();

📊 Model Preview

// Share a model preview (JSON representation)
$user = User::find(1);
$link = ShareLink::create([
    'type' => 'model',
    'class' => User::class,
    'id' => $user->id
])
->expiresIn(30)
->generate();

🔥 Advanced Security Features

// Burn-after-reading link with IP restrictions
$link = ShareLink::create('/secure/document.pdf')
    ->expiresIn(60)
    ->burnAfterReading() // Self-destructs after first access
    ->metadata([
        'allowed_ips' => ['192.168.1.0/24', '10.0.0.1'],
        'denied_ips' => ['192.168.1.100']
    ])
    ->generate();

// Signed URL for extra security
$signedUrl = ShareLink::signedUrl($link, now()->addHour());

🔧 Requirements

  • PHP 8.3+
  • Laravel 11.0+ | 12.0+

📚 Complete Documentation

For comprehensive documentation, examples, and advanced usage guides, visit our Wiki:

📖 👉 Laravel ShareLink Wiki

The wiki includes:

🎨 Artisan Commands

Laravel ShareLink includes powerful CLI commands for managing your share links:

# Create a new share link
php artisan sharelink:create /path/to/file --expires=60 --max-clicks=5

# List all share links
php artisan sharelink:list --active --expired

# Revoke a specific link
php artisan sharelink:revoke abc123xyz

# Clean up expired links
php artisan sharelink:prune --days=7

🔧 Configuration

The package comes with sensible defaults, but you can customize everything:

// config/sharelink.php
return [
    'route' => [
        'prefix' => 'share',
        'middleware' => ['web'],
    ],
    
    'security' => [
        'signed_routes' => [
            'enabled' => true,
            'required' => false,
        ],
        'rate_limiting' => [
            'enabled' => true,
            'max_attempts' => 10,
        ],
        'password_throttling' => [
            'enabled' => true,
            'max_attempts' => 5,
        ],
    ],
    
    'delivery' => [
        'x_sendfile' => false,
        'x_accel_redirect' => false,
    ],
];

🧪 Testing

composer test

🤝 Contributing

Please see CONTRIBUTING.md for details.

🔒 Security

If you discover any security-related issues, please email jms@grazulex.be instead of using the issue tracker.

📝 Changelog

Please see the Wiki Changelog for more information on what has changed recently.

📄 License

The MIT License (MIT). Please see License File for more information.

👥 Credits

💬 Support

Laravel ShareLink - Secure, time-limited sharing for Laravel applications
with comprehensive audit trails and advanced security features.

💼 Need Custom Laravel Solutions?

Laravel ShareLink is maintained by Jean-Marc Strauven, creator of 17+ Laravel packages.

🚀 I Can Help With:

🔐 Secure File Sharing & Access Control

  • Custom file management systems
  • Advanced permission systems
  • Temporary access solutions
  • Integration with cloud storage (S3, Azure, etc.)

📦 Custom Laravel Package Development

  • Build tailored packages for your specific needs
  • Internal tools for your team
  • Integration with third-party services
  • €5,000-€10,000 depending on complexity

🏗️ Complete Laravel Applications

  • SaaS platforms
  • Document management systems
  • Collaboration tools
  • €8,000-€15,000 for MVP

👨‍💻 About Me:

  • 15+ years Laravel/PHP expertise
  • Ex-CTO at Delcampe (millions of users)
  • Chapter Lead at BNP Paribas Fortis
  • 6,000+ package downloads across 17+ packages

📬 Let's Talk:

💡 Building a Laravel SaaS or need custom features? I'd love to help bring your project to life.

⭐ Show Your Support

If Laravel ShareLink is useful for your project:

  • Give it a ⭐ on GitHub
  • Share it with other Laravel developers
  • Sponsor my work ❤️

grazulex/laravel-sharelink 适用场景与选型建议

grazulex/laravel-sharelink 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.18k 次下载、GitHub Stars 达 126, 最近一次更新时间为 2025 年 08 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「temporary」 「laravel」 「secure」 「download」 「token」 「signed-url」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 grazulex/laravel-sharelink 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 grazulex/laravel-sharelink 我们能提供哪些服务?
定制开发 / 二次开发

基于 grazulex/laravel-sharelink 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.18k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 126
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 126
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-08