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

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

majo40/link-preview
===================

Link preview generation for PHP with Laravel support

v1.3(7y ago)01.7kMITPHPPHP &gt;=5.5.0

Since Dec 19Pushed 7y ago1 watchersCompare

[ Source](https://github.com/majo40/link-preview)[ Packagist](https://packagist.org/packages/majo40/link-preview)[ Docs](http://github.com/dusterio/link-preview)[ RSS](/packages/majo40-link-preview/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (19)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

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 60% 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 ~106 days

Recently: every ~128 days

Total

17

Last Release

2825d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

v1.2.3PHP &gt;=5.5.0

### Community

Maintainers

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

---

Top Contributors

[![dusterio](https://avatars.githubusercontent.com/u/11039918?v=4)](https://github.com/dusterio "dusterio (42 commits)")[![kasp3r](https://avatars.githubusercontent.com/u/798379?v=4)](https://github.com/kasp3r "kasp3r (19 commits)")[![j3j5](https://avatars.githubusercontent.com/u/1239921?v=4)](https://github.com/j3j5 "j3j5 (2 commits)")[![edueo](https://avatars.githubusercontent.com/u/6653555?v=4)](https://github.com/edueo "edueo (2 commits)")[![service-paradis](https://avatars.githubusercontent.com/u/12817388?v=4)](https://github.com/service-paradis "service-paradis (2 commits)")[![majo40](https://avatars.githubusercontent.com/u/16256598?v=4)](https://github.com/majo40 "majo40 (2 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/majo40-link-preview/health.svg)

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

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically resolving conflicts between them

341682.2k18](/packages/gehrisandro-tailwind-merge-laravel)[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)[amranidev/laracombee

Recommendation system for laravel

11636.7k1](/packages/amranidev-laracombee)

PHPackages © 2026

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