Parser contracts), enabling integration with niche platforms (e.g., internal docs, proprietary APIs) without vendor lock-in.guzzlehttp/guzzle (for HTTP requests) and Laravel’s cache/database. No heavy frameworks or monolithic dependencies.Preview::forget()) are needed for dynamic content.// Blade
@preview('https://example.com', ['width' => 500])
// Controller
$preview = Preview::get('https://twitter.com');
/api/link-preview endpoint).GeneratePreviewJob) for background processing.GeneratePreviewJob::dispatch($url)->onQueue('previews');
composer.json constraints.config/cache.php is configured.composer require teners/laravel-link-preview
php artisan vendor:publish --provider="Teners\LinkPreview\LinkPreviewServiceProvider"
config/link-preview.php) and adjust:
cache_driver (e.g., redis)timeout (e.g., 10s for external APIs)parsers (add custom classes if needed).config/link-preview.php to avoid environment-specific overrides.'debug' => true) to log parser output.Preview::get($url, ['debug' => true]) for troubleshooting./api/link-preview endpoints.retry_after).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| External API down (Twitter/X) | Broken previews for social links | Fallback to generic preview + alerting |
| Cache stampede | High DB/Redis load | Use probabilistic early expiration |
| Parser timeout | Slow responses | Increase timeout or use async jobs |
| Cache corruption | Stale previews | Manual invalidation + health checks |
| Rate limiting | Throttled requests | Queue delays + retry logic |
Preview::get()).How can I help you explore Laravel packages today?