PHPackages                             cardei/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. cardei/link-preview

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cardei/link-preview
===================

Link preview generation for Laravel

v2.3.0(1y ago)4648↓50%MITPHPPHP &gt;=8.2

Since Oct 8Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (5)Versions (8)Used By (0)

Laravel Link 🔗 Preview (βETA) 🚧 WIP - Work In Progress
======================================================

[](#laravel-link--preview-βeta--wip---work-in-progress)

**Link preview generation 🛠️ for Laravel 🚀 applications.** This package 📦 generates link previews for Laravel applications, similar to how social media platforms display link previews when a URL is shared.

Features 🌟
----------

[](#features-)

- **Automatic Metadata Extraction** 📝: Extracts titles 🏷️, descriptions 📄, and images 🖼️ from URLs to generate rich link previews.
- **Supports Popular Platforms** 🌐: Built-in support for platforms like YouTube ▶️ and Vimeo 🎥 for embedded previews.
- **Customizable Configuration** ⚙️: Fine-tune 🔧 the package to meet your application's specific requirements.
- **Laravel Integration** 🤝: Seamlessly integrates into your Laravel projects with service providers and facades.
- **Simple Usage** 😊: Easy to implement in any controller 🎛️ or service.

Compatibility ✅
---------------

[](#compatibility-)

- **PHP Version**: PHP &gt;= 8.2 🐘
- **Laravel Versions**: Laravel 10.x and 11.x 🚀

### Dependencies 📦

[](#dependencies-)

- **Guzzle** (`guzzlehttp/guzzle`): ^7.4 - For HTTP 🌐 requests to fetch URL metadata.
- **Symfony Dom Crawler** (`symfony/dom-crawler`): ^7.0 - For parsing HTML content 📄.
- **Symfony CSS Selector** (`symfony/css-selector`): ^7.0 - For extracting metadata from the parsed HTML.

Installation 🛠️
---------------

[](#installation-️)

To install the package via Composer, run the following command:

```
composer require cardei/link-preview
```

After installation, you can publish the configuration file if you need to customize the settings:

```
php artisan vendor:publish --tag=link-preview-config
```

This will create a configuration file at `config/link-preview.php`.

### Requirements 📋

[](#requirements-)

- **PHP &gt;= 8.2** 🐘
- **Laravel 10.x or 11.x** 🚀

### Configuration ⚙️

[](#configuration-️)

The package provides a configuration file that can be published using the `vendor:publish` command. By default, the package includes basic configuration for logging 📝 and URL processing:

```
return [
    'enable_logging' => env('LINK_PREVIEW_ENABLE_LOGS', false),
];
```

- **`enable_logging`**: If set to `true` ✅, the package will log information about the URLs being processed when `APP_DEBUG=true`.

To enable logging, you can add the following to your `.env` file:

```
APP_DEBUG=true
LINK_PREVIEW_ENABLE_LOGS=true

```

Usage 💻
-------

[](#usage-)

### Generating Link Previews 🔗

[](#generating-link-previews-)

The package automatically detects URLs and generates previews using metadata from the target URL (e.g., titles 🏷️, images 🖼️, descriptions 📄). It supports platforms such as YouTube ▶️, Vimeo 🎥, and general HTML pages 📄.

To use the package, simply call the `link-preview` service in your Laravel controllers or services:

```
$linkPreview = app('link-preview');
$preview = $linkPreview->setUrl('https://example.com')->getPreview();
```

You can then access metadata like `title` 🏷️, `description` 📄, and `cover image` 🖼️ from the `$preview` object.

### Supported Platforms 🌐

[](#supported-platforms-)

- **YouTube** ▶️: Automatically generates embedded previews for YouTube links. **Note**: Integration with the YouTube API is required for optimal performance. This is particularly important when running the package from cloud instances, as direct page scraping for YouTube links might fail due to network restrictions or bot detection mechanisms. Using the YouTube API ensures consistent and reliable previews.
- **Vimeo** 🎥: Similar to YouTube, generates embedded previews for Vimeo links.
- **General HTML Links** 🌍: Extracts metadata such as titles 🏷️, descriptions 📄, and images 🖼️ from any general webpage.

Why Use Laravel Link Preview? 🤔
-------------------------------

[](#why-use-laravel-link-preview-)

- **Simplicity** 😊: This package is designed to be easy to integrate and use within any Laravel project, with minimal configuration required.
- **Rich Integration** 💎: Direct integration with Laravel services and easy access via facades.
- **Customizable** ⚙️: Configuration options allow you to tailor the package's behavior to your specific needs, including the ability to add new parsers.
- **Actively Developed** 🛠️: Ongoing support and compatibility with the latest versions of Laravel.

Integration 🤝
-------------

[](#integration-)

The package provides seamless integration into your Laravel projects by including:

- **Service Providers** 🛠️: The `LaravelServiceProvider` is automatically registered.
- **Facades** 🏷️: Use the provided facade to easily access the `link-preview` functionality.

### Example: Using in a Controller 📄

[](#example-using-in-a-controller-)

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Cardei\LinkPreview\Facades\LinkPreview;

class PreviewController extends Controller
{
    public function showPreview(Request $request)
    {
        $url = $request->input('url');
        $preview = LinkPreview::setUrl($url)->getPreview();

        return view('preview', ['preview' => $preview]);
    }
}
```

TODO 📝
------

[](#todo-)

- **Support More Platforms** 🌐: Expand support for additional platforms, such as SoundCloud 🎶 and TikTok 🎵.
- **Advanced Error Handling** ⚠️: Improve error handling for failed previews.
- **Caching** 🗄️: Implement caching for previews to avoid multiple requests for the same URL.
- **Internationalization** 🌍: Add support for parsing metadata in different languages.

Versioning and Branches 📌
-------------------------

[](#versioning-and-branches-)

- **v1.0.0 - 1.0.1**: Supports Laravel 10.x 🚀
- **v2.x**: Supports Laravel 11.x and newer versions 🚀

Branches:

- `main` 🚀: Default branch with the latest stable version ready for production.
- `dev-main` 🛠️: Development branch with the latest updates.
- `2.1.0-DEV` 🚧: Latest development version for Laravel 11.x support.

Documentation 📚
---------------

[](#documentation-)

For detailed documentation, refer to the [GitHub Wiki](https://github.com/cardei/laravel-link-preview/wiki).

Contributing 🤝
--------------

[](#contributing-)

Contributions are always welcome! If you'd like to contribute, please fork this repository, make your changes, and submit a pull request 📥.

License 📜
---------

[](#license-)

This package is open-sourced software licensed under the [MIT license](LICENSE).

Support 🆘
---------

[](#support-)

For issues and feature requests, please visit the [GitHub Issues](https://github.com/cardei/laravel-link-preview/issues) page.

If you have any questions or need support, you can contact [M. Catalin Cardei](mailto:mc@cardei.studio).

Why Laravel Link Preview is Better? 🏆
-------------------------------------

[](#why-laravel-link-preview-is-better-)

- **Native Laravel Integration** 🤝: Unlike other link preview libraries that require extensive setup, this package is designed with Laravel in mind, providing native support for service providers and facades.
- **Modular Parser System** 🔧: The parser system allows for easy addition of custom parsers, making it extensible.
- **Lightweight and Fast** ⚡: Optimized for performance, it does not add unnecessary overhead to your application.
- **Open Source and Transparent** 🔍: The code is available on GitHub, providing transparency and the ability to modify the package to fit your needs.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance48

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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 ~187 days

Recently: every ~234 days

Total

6

Last Release

381d ago

Major Versions

1.0.0.x-dev → 2.0.0.x-dev2024-03-13

PHP version history (3 changes)v1.0.0PHP &gt;=5.5.0

1.0.0.x-devPHP &gt;=8.1

2.0.0.x-devPHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/f891bc453a00408b247c5f1d7e649f60dde07738b88be95190c14e91f025d74a?d=identicon)[cardei](/maintainers/cardei)

---

Top Contributors

[![cardei](https://avatars.githubusercontent.com/u/1158862?v=4)](https://github.com/cardei "cardei (17 commits)")

---

Tags

urlphplaravelpreviewscraping

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[dusterio/link-preview

Link preview generation for PHP with Laravel support

126326.6k3](/packages/dusterio-link-preview)[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[monicahq/laravel-cloudflare

Add Cloudflare ip addresses to trusted proxies for Laravel.

3372.7M4](/packages/monicahq-laravel-cloudflare)[kra8/laravel-snowflake

Snowflake for Laravel and Lumen.

188402.3k6](/packages/kra8-laravel-snowflake)[gallib/laravel-short-url

A Laravel package to shorten urls

16516.4k](/packages/gallib-laravel-short-url)[laracrafts/laravel-url-shortener

Powerful URL shortening tools in Laravel

97110.7k](/packages/laracrafts-laravel-url-shortener)

PHPackages © 2026

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