UrlShortener facade/class, allowing:
ServiceProvider.hashids), and storage (supports custom tables).urls table (migrations provided), but schema is simple and adaptable to existing systems.shorten($longUrl) → Returns shortened URL.redirect($shortCode) → Handles HTTP 301/302 redirects./r/{code}).redirect() calls.$longUrl input to prevent SSRF or XSS in redirects.hashids with custom salt).hashids) meet security/compliance requirements?short-unique-id).composer require mosufy/url-shortener
php artisan vendor:publish --provider="Mosufy\UrlShortener\UrlShortenerServiceProvider"
php artisan migrate
config/url-shortener.php (e.g., hash length, table name).routes/web.php:
Route::get('/r/{code}', [\Mosufy\UrlShortener\Facades\UrlShortener::class, 'redirect']);
UrlShortener facade methods.hashids package).redirect() calls.throttle middleware).hashids or Laravel core dependencies.urls table indexes (e.g., code column).opcache memory for hash generation.throttle:60,1).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Database downtime | Redirects fail (500 errors) | Fallback to static file redirects (e.g., Nginx). |
| Hash collision | Duplicate URLs or 404s | Increase code length or use UUIDs. |
| Malicious long URLs | SSRF/XSS via redirects | Validate URLs against a allowlist. |
| High traffic | Slow redirects (CPU-bound hashing) | Cache redirects; use faster hash algorithms. |
| Package abandonment | No security updates | Fork and maintain; monitor for CVEs. |
How can I help you explore Laravel packages today?