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
π 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 [email protected] 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.
πΌ 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:
- π§ [email protected]
- πΌ LinkedIn Profile
- π» Available on Malt
π‘ 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 β€οΈ