PHPackages                             juniora/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. juniora/link-preview

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

juniora/link-preview
====================

Link preview generation for PHP with Laravel support

v1.4.0(1y ago)01.4k↓66.7%MITPHPPHP ^8.0

Since Dec 14Pushed 1y agoCompare

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

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

Link Preview
============

[](#link-preview)

[![Build Status](https://camo.githubusercontent.com/c5a0f5c1c1212b530e3f289dfffc5a273bdb670b6c03e1d841c14365de8c9c81/68747470733a2f2f7472617669732d63692e6f72672f647573746572696f2f6c696e6b2d707265766965772e737667)](https://travis-ci.org/dusterio/link-preview)[![Code Climate](https://camo.githubusercontent.com/a3f804cb82aacc4937847781b94f6c39546d117754433c33d8bbd0b1c3796eda/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f647573746572696f2f6c696e6b2d707265766965772f6261646765732f6770612e737667)](https://codeclimate.com/github/dusterio/link-preview/badges)[![Test Coverage](https://camo.githubusercontent.com/f82611f4da9a4794d1eaef11d97265bc4b23c81d06af6d86b527573ce2e96eed/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f647573746572696f2f6c696e6b2d707265766965772f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/dusterio/link-preview/badges)[![Total Downloads](https://camo.githubusercontent.com/272d6fb4c3a395c6dc5a869340895f0a7e539566deba547d83f69ac3bf548167/68747470733a2f2f706f7365722e707567782e6f72672f647573746572696f2f6c696e6b2d707265766965772f642f746f74616c2e737667)](https://packagist.org/packages/dusterio/link-preview)[![Latest Stable Version](https://camo.githubusercontent.com/6f98c4e807debf64057dec2007fe96fa1ba44123867455ab57a38b64c6f04ba0/68747470733a2f2f706f7365722e707567782e6f72672f647573746572696f2f6c696e6b2d707265766965772f762f737461626c652e737667)](https://packagist.org/packages/dusterio/link-preview)[![Latest Unstable Version](https://camo.githubusercontent.com/b6e6725f209191773b7653b2133ac8fe1efbe40a52214f1e4cf9e4590745c1fa/68747470733a2f2f706f7365722e707567782e6f72672f647573746572696f2f6c696e6b2d707265766965772f762f756e737461626c652e737667)](https://packagist.org/packages/dusterio/link-preview)[![License](https://camo.githubusercontent.com/b5b44adc902c73955f53bff60bb55fedb8623fa444c47445867dcf781bad9890/68747470733a2f2f706f7365722e707567782e6f72672f647573746572696f2f6c696e6b2d707265766965772f6c6963656e73652e737667)](https://packagist.org/packages/dusterio/link-preview)

A PHP class that consumes an HTTP(S) link and returns an array of preview information. Think of Facebook sharing - whenever you paste a link, it goes to specified page and fetches some details.

Initially based on [kasp3r/link-preview](https://github.com/kasp3r/link-preview) that seems to be abandoned.

Includes integrations with: Laravel 5

Dependencies
------------

[](#dependencies)

- PHP &gt;= 5.5
- Guzzle &gt;= 6.1
- Symfony DomCrawler &gt;= 3.0

Installation via Composer
-------------------------

[](#installation-via-composer)

To install simply run:

```
composer require dusterio/link-preview

```

Or add it to `composer.json` manually:

```
{
    "require": {
        "dusterio/link-preview": "~1.2"
    }
}
```

Direct usage
------------

[](#direct-usage)

```
use Dusterio\LinkPreview\Client;

$previewClient = new Client('https://www.boogiecall.com/en/Melbourne');

// Get previews from all available parsers
$previews = $previewClient->getPreviews();

// Get a preview from specific parser
$preview = $previewClient->getPreview('general');

// Convert output to array
$preview = $preview->toArray();
```

**Output**

```
array(4) {
  ["cover"]=>
  string(94) "https://cdn.boogiecall.com/media/images/872398e3d9598c494a2bed72268bf018_1440575488_7314_s.jpg"
  ["images"]=>
  array(8) {
    [0]=>
    string(94) "https://cdn.boogiecall.com/media/images/872398e3d9598c494a2bed72268bf018_1440575488_7314_s.jpg"
    [1]=>
    string(94) "https://cdn.boogiecall.com/media/images/b18970cd4c808f4dcdf7c319779ab9c6_1457347623_2419_s.jpg"
  }
  ["title"]=>
  string(44) "Events, parties & live concerts in Melbourne"
  ["description"]=>
  string(107) "List of events in Melbourne. Nightlife, best parties and concerts in Melbourne, event listings and reviews."
}

```

Timeouts and errors
-------------------

[](#timeouts-and-errors)

```
// Default connect timeout is 5 seconds, you can change it to anything you want
$previewClient->getParser('general')->getReader()->config(['connect_timeout' => 3.14]);

// Default maximum redirect count is 10, but you can change it too
$previewClient->getParser('general')->getReader()->config(['allow_redirects' => ['max' => 10]]);

// If there is a network error (DNS, connect, etc), we throw ConnectionErrorException
try {
    $previews = $previewClient->getPreviews();
} catch (\Dusterio\LinkPreview\Exceptions\ConnectionErrorException $e) {
    echo "Oh no!";
}
```

### YouTube example

[](#youtube-example)

```
use Dusterio\LinkPreview\Client;

$previewClient = new LinkPreview('https://www.youtube.com/watch?v=v1uKhwN6FtA');

// Only parse YouTube specific information
$preview = $previewClient->getPreview('youtube');

var_dump($preview->toArray());
```

**Output**

```
array(2) {
  ["embed"]=>
  string(128) ""
  ["id"]=>
  string(11) "v1uKhwN6FtA"
}

```

### Usage in Laravel 5

[](#usage-in-laravel-5)

```
// Add in your config/app.php

'providers' => [
    '...',
    'Dusterio\LinkPreview\Integrations\LaravelServiceProvider',
];

'aliases' => [
    '...',
    'Preview'    => 'Dusterio\LinkPreview\Integrations\LaravelFacade',
];

// Set target url
Preview::setUrl('https://www.boogiecall.com');

// Get parsed HTML tags as a plain array
Preview::getPreview('general')->toArray();

// In case of redirects, see what the final url was
echo Preview::getUrl();
```

Todo
----

[](#todo)

1. Add more unit and integration tests
2. Update documentation
3. Add more parsers

License
-------

[](#license)

The MIT License (MIT) Copyright (c) 2016 Denis Mysenko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance43

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.3% 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 ~72 days

Total

2

Last Release

448d ago

### Community

Maintainers

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

---

Top Contributors

[![dusterio](https://avatars.githubusercontent.com/u/11039918?v=4)](https://github.com/dusterio "dusterio (49 commits)")[![kasp3r](https://avatars.githubusercontent.com/u/798379?v=4)](https://github.com/kasp3r "kasp3r (19 commits)")[![ejunker](https://avatars.githubusercontent.com/u/4758?v=4)](https://github.com/ejunker "ejunker (3 commits)")[![nimah79](https://avatars.githubusercontent.com/u/20343056?v=4)](https://github.com/nimah79 "nimah79 (3 commits)")[![service-paradis](https://avatars.githubusercontent.com/u/12817388?v=4)](https://github.com/service-paradis "service-paradis (2 commits)")[![edueo](https://avatars.githubusercontent.com/u/6653555?v=4)](https://github.com/edueo "edueo (2 commits)")[![GCalmels](https://avatars.githubusercontent.com/u/5655839?v=4)](https://github.com/GCalmels "GCalmels (2 commits)")[![j3j5](https://avatars.githubusercontent.com/u/1239921?v=4)](https://github.com/j3j5 "j3j5 (2 commits)")[![jdrieghe](https://avatars.githubusercontent.com/u/12606789?v=4)](https://github.com/jdrieghe "jdrieghe (1 commits)")[![benwilkins](https://avatars.githubusercontent.com/u/1360229?v=4)](https://github.com/benwilkins "benwilkins (1 commits)")

---

Tags

urlphplaravelpreviewscraping

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/juniora-link-preview/health.svg)](https://phpackages.com/packages/juniora-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)
