PHPackages                             teners/laravel-link-preview - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. teners/laravel-link-preview

ActiveLibrary[Caching](/categories/caching)

teners/laravel-link-preview
===========================

A Laravel package for extracting link previews with customizable parsers, and caching support

v0.1.1(8mo ago)53.4k↓45%MITPHP

Since Feb 10Pushed 3mo agoCompare

[ Source](https://github.com/Teners-net/laravel-link-preview)[ Packagist](https://packagist.org/packages/teners/laravel-link-preview)[ Docs](https://github.com/Teners-net/laravel-link-preview#readme)[ RSS](/packages/teners-laravel-link-preview/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (6)Used By (0)

Laravel Link Preview
====================

[](#laravel-link-preview)

[![Laravel Link Preview](https://private-user-images.githubusercontent.com/30179079/393251031-c8960294-e74a-4649-aae1-8a9d0a2e547d.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQ0MDI4ODcsIm5iZiI6MTc3NDQwMjU4NywicGF0aCI6Ii8zMDE3OTA3OS8zOTMyNTEwMzEtYzg5NjAyOTQtZTc0YS00NjQ5LWFhZTEtOGE5ZDBhMmU1NDdkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzI1VDAxMzYyN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJmN2I2ZTVhYmQ5M2ZmOTk2ODdjZGI1M2Y0ZDRkYzVmYjI4YWU1MTBhMjhlZDU0NWMxN2NlNTBjMDcxNDY5ZTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.boS3Uxw7Acga0AL6QhPITbu2LKAlkYO8Qb9lBCLbp1c)](https://private-user-images.githubusercontent.com/30179079/393251031-c8960294-e74a-4649-aae1-8a9d0a2e547d.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQ0MDI4ODcsIm5iZiI6MTc3NDQwMjU4NywicGF0aCI6Ii8zMDE3OTA3OS8zOTMyNTEwMzEtYzg5NjAyOTQtZTc0YS00NjQ5LWFhZTEtOGE5ZDBhMmU1NDdkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzI1VDAxMzYyN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJmN2I2ZTVhYmQ5M2ZmOTk2ODdjZGI1M2Y0ZDRkYzVmYjI4YWU1MTBhMjhlZDU0NWMxN2NlNTBjMDcxNDY5ZTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.boS3Uxw7Acga0AL6QhPITbu2LKAlkYO8Qb9lBCLbp1c)

A powerful and flexible Laravel package for extracting rich link previews with customizable parsers, intelligent caching, and support for Twitter/X, YouTube, and more. - [Some use cases](docs/use-cases.md)

[![Latest Version on Packagist](https://camo.githubusercontent.com/032c9b1335df0417f5f26facef37ab02a02e7e352de23f9b48c48350460a1524/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74656e6572732f6c61726176656c2d6c696e6b2d707265766965772e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teners/laravel-link-preview)[![Issues](https://camo.githubusercontent.com/b1c702e11e7f5de4aaeb9e11b8e89210d18f22d8fa56a8850b7f02c602b6b8b2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f54656e6572732d6e65742f6c61726176656c2d6c696e6b2d707265766965773f7374796c653d666c61742d737175617265)](https://github.com/Teners-net/laravel-link-preview/issues)[![Stars](https://camo.githubusercontent.com/a1e0a9376448c259e81da36090341aa07907907a001b73700b46e7662d1da7f7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f54656e6572732d6e65742f6c61726176656c2d6c696e6b2d707265766965773f7374796c653d666c61742d737175617265)](https://github.com/Teners-net/laravel-link-preview/stargazers)[![License](https://camo.githubusercontent.com/7523f2387cfea9cca5e179667156600eb7877b8e52cd2774273580b70b4767df/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f54656e6572732d6e65742f6c61726176656c2d6c696e6b2d707265766965773f7374796c653d666c61742d737175617265)](https://github.com/Teners-net/laravel-link-preview/blob/main/LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/ac90dca9b6684014fb8e6bc7db3bcc48f56b3d6d92dc9c1fa59562437aab4205/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74656e6572732f6c61726176656c2d6c696e6b2d707265766965772e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teners/laravel-link-preview)

Features
--------

[](#features)

- **Smart Platform Detection** - Automatically detects and handles Twitter/X, YouTube, Vimeo, and generic HTML
- **Flexible Caching** - Database or Laravel cache system with configurable expiration
- **Highly Configurable** - Extensive configuration options for timeouts, redirects, SSL verification
- **Mobile-Optimized** - Smart user agent handling for better compatibility
- **Extensible Architecture** - Easy to add custom parsers for new platforms
- **Rich Metadata** - Extracts titles, descriptions, images, videos, authors, and more
- **Auto-Pruning** - Automatic cleanup of expired cached entries

The package automatically detects different platforms and uses specialized parsers:

- **Twitter/X** - Enhanced metadata extraction with fallback mechanisms
- **Generic HTML** - Open Graph, Twitter Cards, and standard HTML meta tags
- **YouTube/Vimeo** - Video-specific metadata (coming soon)

Installation
------------

[](#installation)

To install Laravel Link Preview via composer, run the following command in your terminal:

```
composer require teners/laravel-link-preview
```

Publish the package configuration file

```
php artisan vendor:publish --provider="Teners\LaravelLinkPreview\LaravelLinkPreviewServiceProvider" --tag="link-preview-config"
```

Run migrations to create the cache table (if using model-based caching):

```
php artisan migrate
```

Usage
-----

[](#usage)

```
use Teners\LaravelLinkPreview\LinkPreview;

// Get link preview for any URL
$preview = LinkPreview::getPreview('https://example.com');

// Returns an array with extracted metadata
/*
[
    'title' => 'Example Website',
    'description' => 'This is an example website description',
    'cover' => 'https://example.com/image.jpg',
    'author' => 'John Doe',
    'keywords' => 'example, website, demo',
    'icon' => 'https://example.com/favicon.ico',
    'video' => 'https://example.com/video.mp4',
    'video_type' => 'video/mp4'
]
*/
```

#### Using the Built-in Route

[](#using-the-built-in-route)

The package includes a convenient route for AJAX requests:

```
// GET request to /link-preview?url=https://example.com
fetch('/link-preview?url=' + encodeURIComponent(url))
    .then(response => response.json())
    .then(data => {
        console.log(data); // Link preview data
    });
```

### Configuration

[](#configuration)

The package provides extensive configuration options in `config/link-preview.php`:

```
// Enable/disable caching
'enable_caching' => env('LINK_PREVIEW_ENABLE_CACHING', true),

// Cache duration in seconds (default: 1 week)
'cache_duration' => env('LINK_PREVIEW_CACHE_DURATION', 604800),

// Cache type: 'model' (database) or 'app' (Laravel cache)
'cache_type' => env('LINK_PREVIEW_CACHE_TYPE', 'model'),

// Request timeout
'timeout' => env('LINK_PREVIEW_TIMEOUT', 15),

// Connection timeout
'connect_timeout' => env('LINK_PREVIEW_CONNECT_TIMEOUT', 10),

// Maximum redirects
'max_redirects' => env('LINK_PREVIEW_MAX_REDIRECTS', 5),

// User agent
'user_agent' => env('LINK_PREVIEW_USER_AGENT', 'Teners/LinkPreview v2.0.0 (Compatible Bot)'),

// SSL verification
'verify_ssl' => env('LINK_PREVIEW_VERIFY_SSL', true),
```

Contributions
-------------

[](#contributions)

Contributions are **welcome** via Pull Requests on [Github](https://github.com/Teners-net/laravel-link-preview).

- Please document any change you made as neccesary in the README.md.
- Follow PSR-12 coding standards
- Write tests for new features
- Update documentation for any changes
- Make one pull request per feature/fix
- Ensure all tests pass

### Roadmap Items (Help Wanted!)

[](#roadmap-items-help-wanted)

- Add Other Parsers to extrack videos
    - YouTube parser
    - Vimeo parser implementation
- JavaScript/Puppeteer reader for dynamic content
- Image size validation and quality checks
- Global CDN cache option
- Instagram parser
- LinkedIn parser

Issues
------

[](#issues)

Please report any issue you encounter in using the package through the [Github Issues](https://github.com/Teners-net/laravel-link-preview/issues) tab.

When reporting issues, please include:

- Laravel version
- PHP version
- Package version
- Code example
- Error messages

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [Emmanuel Adesina](https://github.com/ThePlatinum)

Contributors list will be added here

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Made with ❤️ by [Teners](https://teners.net) - if this package helped you ⭐ [Star us on GitHub](https://github.com/Teners-net/laravel-link-preview)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance71

Regular maintenance activity

Popularity26

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~279 days

Total

3

Last Release

264d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/69c867925d2ac9e246b66bba210db0065cddb0d169c44db0ffe43f860a48831d?d=identicon)[ThePlatinum](/maintainers/ThePlatinum)

![](https://www.gravatar.com/avatar/28dc1abd50d8b3e3c2c12cb0ae28bb19dba541588ab27423c75ea4427e0cec50?d=identicon)[teners](/maintainers/teners)

---

Top Contributors

[![ThePlatinum](https://avatars.githubusercontent.com/u/30179079?v=4)](https://github.com/ThePlatinum "ThePlatinum (16 commits)")

---

Tags

phplaravellaravel-packagemetadatacachingparsinglink previewHTML Parserweb-scraping link informationcontent previewlink extractorteners

### Embed Badge

![Health badge](/badges/teners-laravel-link-preview/health.svg)

```
[![Health](https://phpackages.com/badges/teners-laravel-link-preview/health.svg)](https://phpackages.com/packages/teners-laravel-link-preview)
```

###  Alternatives

[swayok/alternative-laravel-cache

Replacements for Laravel's redis and file cache stores that properly implement tagging idea. Powered by cache pool implementations provided by http://www.php-cache.com/

202541.1k6](/packages/swayok-alternative-laravel-cache)[ymigval/laravel-model-cache

Laravel package for caching Eloquent model queries

7642.2k3](/packages/ymigval-laravel-model-cache)[alexmg86/laravel-sub-query

Laravel subquery

7538.4k](/packages/alexmg86-laravel-sub-query)[alekseykorzun/memcached-wrapper-php

Optimized PHP 5 wrapper for Memcached extension that supports dog-piling, igbinary and local storage

2984.6k1](/packages/alekseykorzun-memcached-wrapper-php)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15191.3k7](/packages/rapidwebltd-rw-file-cache)[swiggles/memcache

Memcache driver for Laravel 5

1449.9k1](/packages/swiggles-memcache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
