PHPackages                             tdonselaar/opengraph - 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. tdonselaar/opengraph

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

tdonselaar/opengraph
====================

A Laravel package to fetch website Open Graph metadata.

v1.1.2(4y ago)07MITPHP

Since Jan 10Pushed 4y agoCompare

[ Source](https://github.com/TDonselaar/OpenGraph)[ Packagist](https://packagist.org/packages/tdonselaar/opengraph)[ RSS](/packages/tdonselaar-opengraph/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (21)Used By (0)

 [ ![Laravel OpenGraph](https://user-images.githubusercontent.com/35127382/56821996-695df500-686d-11e9-9c59-c70d0c78c80e.png) ](https://shweshi.github.io/OpenGraph/)

 **[OpenGraph](https://opengraph.shashi.dev/) is a laravel package to fetch Open Graph metadata of a website/link.**

 [ ![Latest Version on Packagist](https://camo.githubusercontent.com/a94b93dedb22eab433ced03b051c24032197325ca4d70fdc14bcea131152a9c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736877657368692f4f70656e47726170682e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/shweshi/OpenGraph) [ ![Total Downloads](https://camo.githubusercontent.com/caf40516c03ca1ec8fc8ae4677d235ad3b24c3e9c51ad9076b7c6beb162510ad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736877657368692f4f70656e47726170682e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/shweshi/OpenGraph) [ ![Scrutinizer Code Quality](https://camo.githubusercontent.com/be9928f4f59d99a2b1a8d14fbf013842b96cd861fe9bc9b12218ce516777d22e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736877657368692f4f70656e47726170682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572) ](https://scrutinizer-ci.com/g/shweshi/OpenGraph/?branch=master) [ ![StyleCI](https://camo.githubusercontent.com/32438a6201fbd957478222b2adb56ddeea580c14a33947f4dc4a889e606d989f/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131363939353636392f736869656c643f6272616e63683d6d6173746572) ](https://styleci.io/repos/116995669) [ ![CodeFactor](https://camo.githubusercontent.com/e9bb07647fa1cceee7e5039da3c6f6806792a19f3b7b01bb057b17764a49c25d/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f736877657368692f6f70656e67726170682f6261646765) ](https://www.codefactor.io/repository/github/shweshi/opengraph) [ ![Build Status](https://camo.githubusercontent.com/ba40da0d6a3399af8cf66c097ff27f7ec4a7a59db9a544bd63d170752bd3d92d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736877657368692f4f70656e47726170682f6261646765732f6275696c642e706e673f623d6d6173746572) ](https://scrutinizer-ci.com/g/shweshi/OpenGraph/build-status/master) [ ![FOSSA Status](https://camo.githubusercontent.com/fd719a43571b99709bbfcc5e4082fe7782c2d6e4f30c52bb355ba87b329db693/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d253246736877657368692532464f70656e47726170682e7376673f747970653d736869656c64) ](https://app.fossa.io/projects/git%2Bgithub.com%2Fshweshi%2FOpenGraph?ref=badge_shield)

Features
--------

[](#features)

- **Easily fetch metadata of a URL.** Laravel OpenGraph fetches all the metadata of a URL.
- **Supports language-specific metadata.** Laravel OpenGraph can fetch metadata in a specific language if webpage supports.
- **Supports twitter metadata.** Laravel OpenGraph supports twitter OG data too.
- **Verify image URL.** Laravel OpenGraph verifies that the image URL in the image metadata is valid or not.

Demo
----

[](#demo)

```
  curl https://laravelopengraph.herokuapp.com/api/fetch?url=ogp.me&allMeta=true&language=en_GB

```

How to use Laravel OpenGraph
----------------------------

[](#how-to-use-laravel-opengraph)

An article can be found on the medium blog:

### Documentation

[](#documentation)

### Installation

[](#installation)

Perform the following operations in order to use this package

- Install via composer

```
composer require "shweshi/opengraph"

```

If you do not run Laravel 5.5 (or higher), then add the service provider in config/app.php:

- **Add Service Provider**Open `config/app.php` and add `shweshi\OpenGraph\Providers\OpenGraphProvider::class,` to the end of `providers` array:

    ```
    'providers' => array(
        ....
        shweshi\OpenGraph\Providers\OpenGraphProvider::class,
    ),

    ```

    Next under the `aliases` array:

    ```
    'aliases' => array(
        ....
        'OpenGraph' => shweshi\OpenGraph\Facades\OpenGraphFacade::class
    ),

    ```

If you do run the package on Laravel 5.5+, package auto-discovery takes care of the magic of adding the service provider.

### Requirements

[](#requirements)

- You need to install the [DOM](http://www.php.net/en/dom) extension.

### How to use

[](#how-to-use)

- After following the above steps,

    ```
    use OpenGraph;

    $data = OpenGraph::fetch("https://unsplash.com/");

    ```

    this will give you an array like this...

    ```
      array (
        'title' => 'Beautiful Free Images & Pictures | Unsplash',
        'description' => 'Beautiful, free images and photos that you can download and use for any project. Better than any royalty free or stock photos.',
        'type' => 'website',
        'url' => 'https://unsplash.com/',
        'image' => 'http://images.unsplash.com/photo-1542841791-1925b02a2bbb?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjEyMDd9&s=aceabe8a2fd1a273da24e68c21768de0',
        'image:secure_url' => 'https://images.unsplash.com/photo-1542841791-1925b02a2bbb?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjEyMDd9&s=aceabe8a2fd1a273da24e68c21768de0',
      )

    ```

    You can also pass an optional parameter either true or false along with URL. When set false it will only fetch basic metadata and in case of true it will fetch all the other optional metadata as well like audio, video, music and twitter metatags as well.

    ```
    $data = OpenGraph::fetch("https://unsplash.com/", true);

    ```

    this will give you an array like this...

    ```
      array (
        'charset' => 'UTF8',
        'viewport' => 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimal-ui',
        'mobile-web-app-capable' => 'yes',
        'apple-mobile-web-app-capable' => 'yes',
        'apple-mobile-web-app-title' => 'Unsplash',
        'application-name' => 'Unsplash',
        'author' => 'Unsplash',
        'msapplication-config' => 'browserconfig.xml',
        'msapplication-TileColor' => '#ffffff',
        'msapplication-TileImage' => 'https://unsplash.com/mstile-144x144.png',
        'theme-color' => '#ffffff',
        'description' => 'Beautiful, free images and photos that you can download and use for any project. Better than any royalty free or stock photos.',
        'twitter:site' => '@unsplash',
        'twitter:title' => 'Beautiful Free Images & Pictures | Unsplash',
        'twitter:description' => 'Beautiful, free images and photos that you can download and use for any project. Better than any royalty free or stock photos.',
        'twitter:url' => 'https://unsplash.com/',
        'twitter:card' => 'summary_large_image',
        'twitter:image' => 'https://images.unsplash.com/photo-1546486610-e9fe4f1e6751?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjEyMDd9',
        'title' => 'Beautiful Free Images & Pictures | Unsplash',
        'type' => 'website',
        'url' => 'https://unsplash.com/',
        'image' => 'http://images.unsplash.com/photo-1546486610-e9fe4f1e6751?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjEyMDd9',
        'image:secure_url' => 'https://images.unsplash.com/photo-1546486610-e9fe4f1e6751?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjEyMDd9',
    )

    ```

    To fetch the metadata in a specific language you can pass the language as the third argument, this value will be used as the Accept-Language header.

    ```
    $url = "https://ogp.me",
    $allMeta = true, // can be false
    $language = 'en' // en-US,en;q=0.8,en-GB;q=0.6,es;q=0.4
    $data = OpenGraph::fetch($url, $allMeta, $language);

    ```

    You can also pass additional Libxml parameters as the fourth argument ($options) . Default options are set to suppress the reporting of errors and warnings

    ```
    $data = OpenGraph::fetch($url, $allMeta, $language, $options);

    ```

    You can use the fifth parameter to set the user-agent ($userAgent) of the request. The default is 'Curl'.

    ```
    $data = OpenGraph::fetch($url, $allMeta, $language, $options, $userAgent);

    ```

### Exception Handling

[](#exception-handling)

The fetch() method, returns a FetchException with aditional data at failure.

```
    try {
        $data = OpenGraph::fetch($url, true);
    } catch (shweshi\OpenGraph\Exceptions\FetchException $e) {
        $message = $e->getMessage();
        $data = $e->getData();
    }

```

### Testing

[](#testing)

```
composer test

```

### Changelog

[](#changelog)

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

### Contributing

[](#contributing)

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

### License

[](#license)

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

[![FOSSA Status](https://camo.githubusercontent.com/f62d72f54953e543e5826465a4a44501b5255154a1f68b25c2b4115c56c0d08d/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d253246736877657368692532464f70656e47726170682e7376673f747970653d6c61726765)](https://app.fossa.io/projects/git%2Bgithub.com%2Fshweshi%2FOpenGraph?ref=badge_large)

### Happy coding!

[](#happy-coding)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 75.2% 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 ~68 days

Recently: every ~78 days

Total

20

Last Release

1734d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/289247f987586232642081deea49956e07fd70c2fa7171f9c5bd458c0b60ccec?d=identicon)[TDonselaar](/maintainers/TDonselaar)

---

Top Contributors

[![shweshi](https://avatars.githubusercontent.com/u/35127382?v=4)](https://github.com/shweshi "shweshi (124 commits)")[![alinmiron](https://avatars.githubusercontent.com/u/9200637?v=4)](https://github.com/alinmiron "alinmiron (28 commits)")[![huulbaek](https://avatars.githubusercontent.com/u/1862741?v=4)](https://github.com/huulbaek "huulbaek (5 commits)")[![sarpavci](https://avatars.githubusercontent.com/u/6714468?v=4)](https://github.com/sarpavci "sarpavci (2 commits)")[![igor-bel](https://avatars.githubusercontent.com/u/13505705?v=4)](https://github.com/igor-bel "igor-bel (1 commits)")[![jurgenbosch](https://avatars.githubusercontent.com/u/7451340?v=4)](https://github.com/jurgenbosch "jurgenbosch (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![fossabot](https://avatars.githubusercontent.com/u/29791463?v=4)](https://github.com/fossabot "fossabot (1 commits)")[![codacy-badger](https://avatars.githubusercontent.com/u/23704769?v=4)](https://github.com/codacy-badger "codacy-badger (1 commits)")[![gavinclive](https://avatars.githubusercontent.com/u/37045788?v=4)](https://github.com/gavinclive "gavinclive (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tdonselaar-opengraph/health.svg)

```
[![Health](https://phpackages.com/badges/tdonselaar-opengraph/health.svg)](https://phpackages.com/packages/tdonselaar-opengraph)
```

###  Alternatives

[shweshi/opengraph

A Laravel package to fetch website Open Graph metadata.

168736.5k1](/packages/shweshi-opengraph)

PHPackages © 2026

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