PHPackages                             jclyons52/page-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. jclyons52/page-preview

ActiveLibrary

jclyons52/page-preview
======================

get info about page links and generate preview images

v1.0.0(10y ago)069MITPHPPHP ~5.5|~7.0

Since May 4Pushed 10y ago2 watchersCompare

[ Source](https://github.com/jclyons52/page-preview)[ Packagist](https://packagist.org/packages/jclyons52/page-preview)[ Docs](https://github.com/jclyons52/page-preview)[ RSS](/packages/jclyons52-page-preview/feed)WikiDiscussions master Synced 2mo ago

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

page-preview
============

[](#page-preview)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f8bb796d6fe8f8edac043315f60fd51f48a17dd918b90d83cea570272683ba21/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a636c796f6e7335322f706167652d707265766965772e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jclyons52/page-preview)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/ec677a3ee0a8bc629c88390b30cefaa19260908d5ce9c3e3cea84906a9d8fa50/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6a636c796f6e7335322f706167652d707265766965772f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/jclyons52/page-preview)[![Coverage Status](https://camo.githubusercontent.com/19a22fd761e0b86708cc7b0fc9bf758abac1365b38c35d410fd5dd70bc729a96/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6a636c796f6e7335322f706167652d707265766965772e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/jclyons52/page-preview/code-structure)[![Quality Score](https://camo.githubusercontent.com/1e8c1ef8df09869e03cceb665c27a45c2c298846431011ee6b0f3ba617afd371/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6a636c796f6e7335322f706167652d707265766965772e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/jclyons52/page-preview)[![Total Downloads](https://camo.githubusercontent.com/bd4cdddc872599451ab2e5baabc7949772886ae36b56c3e288a104e3494221c4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a636c796f6e7335322f706167652d707265766965772e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jclyons52/page-preview)

Creates link previews to pages with thumbnail, title and description

[demo](http://page-preview.jclyons-blog.com/)

Install
-------

[](#install)

Via Composer

```
$ composer require jclyons52/page-preview
```

Usage
-----

[](#usage)

```
$previewManager = PreviewManager::create();
$preview = $previewManager->fetch('https://somewebsite.com');
echo $preview->render(); // returns bootstrap media link preview
echo $preview->toJson(); // returns json string of preview attributes
```

or do it inline:

```
PreviewManager::create()->fetch('https://somewebsite.com')->render();
```

Use another one of the other default templates:

```
$previewManager->render('thumbnail');
```

define your own templates:

```
$previewManager->fetch('https://somewebsite.com')->render('myAwesomeTemplate', '/path/to/template/directory');
```

caching
-------

[](#caching)

Http calls are slow, so to speed up your response times you may want to cache your previews. This package can take any psr-6 compliant cache driver as a parameter.

```
$pool = new Pool();

$previewManager = PreviewManager::create($pool);

$preview = $previewManager->findOrFetch('http://www.example.com/directory');

$previewManager->cache($preview);
```

The data available for you templates will be:

- string $title - meta title or page title if not found in meta
- string $description - meta description
- string $url - link url
- array $images - array of image urls
- array $meta - array of meta values with their names as keys

If you're usign information from tags such as the twitter meta tags (or anything seperated with ':') you may want to use the unFlatten function to get a multi level array.

This meta:

```

```

using unFlatten:

```
$meta = $preview->meta->unFlatten()['twitter'];
```

Would produce the following array:

```
[
    "card" => "app",
    "site" => "@TwitterDev",
    "description" => "Cannonball is the fun way to create and share stories and poems on your phone. Start with a beautiful image from the gallery, then choose words to complete the story and share it with friends.",
    "app" => [
        "country" => "US",
        "name" => [
            "iphone" => "Cannonball",
            "ipad" => "Cannonball",
            "googleplay" => "Cannonball",
        ],
        "id" => [
            "iphone" => "929750075",
            "ipad" => "929750075",
            "googleplay" => "io.fabric.samples.cannonball",
        ],
        "url" => [
            "iphone" => "cannonball://poem/5149e249222f9e600a7540ef",
            "ipad" => "cannonball://poem/5149e249222f9e600a7540ef",
            "googleplay" => "http://cannonball.fabric.io/poem/5149e249222f9e600a7540ef",
        ],
    ]

];
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Joseph Lyons](https://github.com/jclyons52)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.4% 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

Unknown

Total

1

Last Release

3658d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/85b74f34a674bb16966f6c18b88495685052a42743a85cfac4341b6790bf2762?d=identicon)[jclyons52](/maintainers/jclyons52)

---

Top Contributors

[![jclyons52](https://avatars.githubusercontent.com/u/6395559?v=4)](https://github.com/jclyons52 "jclyons52 (54 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")

---

Tags

page previewJclyons52

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/jclyons52-page-preview/health.svg)

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

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.3k86.3M2.2k](/packages/symfony-symfony)[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k348.9M2.5k](/packages/symfony-cache)[google/auth

Google Auth Library for PHP

1.4k272.7M161](/packages/google-auth)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M648](/packages/sylius-sylius)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M232](/packages/nelmio-api-doc-bundle)

PHPackages © 2026

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