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

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

hazaveh/php-link-preview
========================

PHP Link Preview library

1.0.4(2y ago)1819.2k—4.1%2[1 issues](https://github.com/hazaveh/php-link-preview/issues)MITPHPPHP &gt;=8.1

Since Sep 27Pushed 2y ago3 watchersCompare

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

READMEChangelogDependencies (6)Versions (6)Used By (0)

 [![](https://camo.githubusercontent.com/ea5021b185985df5e75c8cf7a3611c0f0ab7f99c346e4d4298613d9bd0aec68f/68747470733a2f2f68617a617665682e6e65742f77702d636f6e74656e742f75706c6f6164732f7068702d6c696e6b2d707265766965772e6a706567)](https://camo.githubusercontent.com/ea5021b185985df5e75c8cf7a3611c0f0ab7f99c346e4d4298613d9bd0aec68f/68747470733a2f2f68617a617665682e6e65742f77702d636f6e74656e742f75706c6f6164732f7068702d6c696e6b2d707265766965772e6a706567)

PHP Link Preview
================

[](#php-link-preview)

PHP Link Preview is a small library that can crawl and return the OG &amp; Meta tags of an URL. This can be used in your applications to display a preview of a URL similar to what happens when you paste a link in Social Media sites or Whatsapp.

### Current Information

[](#current-information)

- `title`: open graph title, if not found page title will be returned
- `description`: open graph description, if not found page description from meta tag is returned
- `image`: open graph image
- `icon`: favicon (if icon is explicitly specified in the HTML source)

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

[](#dependencies)

- PHP &gt;= 8.2
- Guzzle &gt;= 6
- Symfony DomCrawler &gt;= 3.0
- Symfony CssSelector &gt;= 3.0

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

[](#installation)

Simply run via composer:

```
composer require hazaveh/php-link-preview

```

Usage
-----

[](#usage)

Create an instance of Client and use `parse` method to crawl a URL.

```
use Hazaveh\LinkPreview\Client;

require_once 'vendor/autoload.php';

$client = new Client();

/**
* Returns an instance of Hazaveh\LinkPreview\Model\Link
* {title, description, image, icon, locale}
*/

$preview = $client->parse("https://hazaveh.net/2023/07/re-inventing-bookmarks-for-teams/");
```

Using Custom Parser
-------------------

[](#using-custom-parser)

Out of the box this library comes with a Parser that uses included extractor classes to extract different pieces of information from the page. You can always use a custom parser that implements `ParserInterface` and have your own logic to extract information from the page.

You are also free to use a Custom Link class which would then include additional information you might want to parse off the website during parsing process.

```
class CustomParser implements ParserInterface
{
    public function parse(string $url): Link
    {
        return new Link(url: $url);
    }
}

$client = new Client(new CustomParser());
```

Contribution
------------

[](#contribution)

Do something cool and add a PR.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 74.6% 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 ~21 days

Total

5

Last Release

880d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/87c0c49081a79a456bf9730ec426e840236cf7ed3ef0596fe31f62c45b0fcf38?d=identicon)[hazaveh](/maintainers/hazaveh)

---

Top Contributors

[![hazaveh](https://avatars.githubusercontent.com/u/12988865?v=4)](https://github.com/hazaveh "hazaveh (47 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![jdecool](https://avatars.githubusercontent.com/u/433926?v=4)](https://github.com/jdecool "jdecool (4 commits)")[![mahdizolar](https://avatars.githubusercontent.com/u/152182086?v=4)](https://github.com/mahdizolar "mahdizolar (2 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[ashallendesign/favicon-fetcher

A Laravel package for fetching website's favicons.

190272.4k3](/packages/ashallendesign-favicon-fetcher)[visuellverstehen/statamic-classify

A useful helper to add CSS classes to all HTML tags generated by the bard editor.

20116.8k](/packages/visuellverstehen-statamic-classify)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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