grazulex / laravel-sharelink
Generate, manage, and secure temporary share links for files, routes, and model previews.
Fund package maintenance!
Grazulex
paypal.me/strauven
Requires
- php: ^8.3
- illuminate/support: ^11.0|^12.0
- nesbot/carbon: ^3.10
- symfony/yaml: ^7.3
Requires (Dev)
- doctrine/dbal: ^4.2
- larastan/larastan: ^3.4
- laravel/pint: ^1.22
- orchestra/testbench: ^9.0|^10.0
- pestphp/pest: ^3.8
- pestphp/pest-plugin-laravel: ^3.2
- rector/rector: ^2.0
README

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
๐ 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:
- ๐ Installation & Setup
- โ๏ธ Configuration
- ๐ฏ Quickstart Guide
- ๐ API Endpoints
- ๐ API Reference
- ๐ก๏ธ Security Features
- ๐ก Events & Observability
- ๐จ CLI Commands
- ๐ Version Matrix
- ๐ Changelog
๐จ 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
- ๐ Report Issues
- ๐ฌ Discussions
- ๐ Documentation
with comprehensive audit trails and advanced security features.