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)1924.1k↓36%2[2 issues](https://github.com/hazaveh/php-link-preview/issues)MITPHPPHP &gt;=8.1CI passing

Since Sep 27Pushed 3mo 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 2d 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

43

—

FairBetter than 89% of packages

Maintenance52

Moderate activity, may be stable

Popularity37

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.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

926d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12988865?v=4)[Mahdi Hazaveh](/maintainers/hazaveh)[@hazaveh](https://github.com/hazaveh)

---

Top Contributors

[![hazaveh](https://avatars.githubusercontent.com/u/12988865?v=4)](https://github.com/hazaveh "hazaveh (48 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 (7 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

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[spatie/crawler

Crawl all internal links found on a website

2.8k18.5M67](/packages/spatie-crawler)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[sproutcms/cms

Enterprise content management and framework

242.5k4](/packages/sproutcms-cms)[blackfire/player

A powerful web crawler and web scraper with Blackfire support

49617.1k](/packages/blackfire-player)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.6M344](/packages/drupal-core-dev)

PHPackages © 2026

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