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

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

umanskyi31/opengraph
====================

Created a new component for Yii2. The Open Graph component for your website

3.0.1(3mo ago)119.7k1MITPHPPHP &gt;=7.4CI failing

Since May 27Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/vumanskyi/yii2-opengraph)[ Packagist](https://packagist.org/packages/umanskyi31/opengraph)[ Docs](https://github.com/vumanskyi/yii2-opengraph)[ RSS](/packages/umanskyi31-opengraph/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (3)Versions (8)Used By (0)

[![](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct.svg)](https://supportukrainenow.org/)

---

Yii2.x Open Graph
=================

[](#yii2x-open-graph)

[![Build Status](https://camo.githubusercontent.com/7450ae9f4f1bde81617be047ab960e6cf10ea9b1cf9fb5c2d30f74a494cb399b/68747470733a2f2f7472617669732d63692e6f72672f76756d616e736b79692f796969322d6f70656e67726170682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vumanskyi/yii2-opengraph)[![StyleCI](https://camo.githubusercontent.com/9936c7ba9c7aa3d7e876b16b05a6e0056bd381f1fca6af5c356fb4a6d2c0ff0a/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3131393839343230372f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/119894207)[![Total Downloads](https://camo.githubusercontent.com/d494d5fe02d8e509e3fbde7b6f3432c2c6d8a3dd9c70151c7459a7f8bbc8272d/68747470733a2f2f706f7365722e707567782e6f72672f756d616e736b796933312f6f70656e67726170682f646f776e6c6f616473)](https://packagist.org/packages/umanskyi31/opengraph)[![Latest Stable Version](https://camo.githubusercontent.com/784d5247b93205454d1568b2e3d68c400ec6d5d1b121587e61c5ac8ad0d9118f/68747470733a2f2f706f7365722e707567782e6f72672f756d616e736b796933312f6f70656e67726170682f762f737461626c65)](https://packagist.org/packages/umanskyi31/opengraph)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://opensource.org/licenses/MIT)

Created a new component for Yii2. The Open Graph component for your website

### Installation

[](#installation)

```
composer require umanskyi31/opengraph

```

or add

```
"umanskyi31/opengraph": "^3.0.0"

```

to the require section of your composer.json file.

### Configuration

[](#configuration)

```
'components' => [
     'opengraph' => [
        'class' => 'umanskyi31\opengraph\OpenGraph',
     ],
     // ...
]
```

### Usage

[](#usage)

You should add component to controller before rendering view.

Example:

```
/**
 * @var OpenGraph $openGraph
 */
 $openGraph = Yii::$app->opengraph;
```

#### How to use

[](#how-to-use)

Add basic attributes:

```
/**
 * @var OpenGraph $openGraph
 */
 $openGraph = Yii::$app->opengraph;

 $openGraph->getBasic()
       ->setUrl('https://umanskyi.com')
       ->setTitle('My_Article_Title')
       ->setDescription('My_Article_Description')
       ->setSiteName('My_Site_Name')
       ->setLocale('pl_PL')
       ->setLocalAlternate(['fr_FR', 'en_US'])
       ->render();
```

Add image attributes:

```
/**
 * @var OpenGraph $openGraph
 */
 $openGraph = Yii::$app->opengraph;

 $openGraph->getImage()
       ->setUrl('https://umanskyi.com/logo.png')
       ->setAttributes([
           'secure_url' => 'https://umanskyi.com/logo.png',
           'width'      => 100,
           'height'     => 100,
           'alt'        => "Logo",
       ])
       ->render();
```

If necessary, an array of images also possible to add the next code:

```
/**
 * @var OpenGraph $openGraph
 */
 $openGraph = Yii::$app->opengraph;

 $openGraph->getImage()
       ->setUrl('https://umanskyi.com/logo.png')
       ->setAttributes([
           'secure_url' => 'https://umanskyi.com/logo.png',
           'width'      => 100,
           'height'     => 100,
           'alt'        => "Logo",
       ])
       ->render();

 $openGraph->getImage()
       ->setUrl('https://umanskyi.com/small_logo.png')
       ->setAttributes([
           'secure_url' => 'https://umanskyi.com/small_logo.png',
           'width'      => 50,
           'height'     => 50,
           'alt'        => "small logo",
       ])
       ->render();

```

Add article attribute:

```
/**
 * @var OpenGraph $openGraph
 */
 $openGraph = Yii::$app->opengraph;

 $openGraph->getArticle()
       ->setAuthor(['http://examples.opengraphprotocol.us/profile.html'])
       ->setTag(['Test_TAG'])
       ->setSection('Front page')
       ->setPublishTime(new \DateTime('2010-10-11'))
       ->render();
```

Add audio attribute:

```
/**
 * @var OpenGraph $openGraph
 */
 $openGraph = Yii::$app->opengraph;

 $openGraph->getAudio()
       ->setAttributes([
         'secure_url' => 'https://umanskyi.com/media/audio/250hz.mp3',
         'type' => 'audio/mpeg'
       ])
       ->setUrl('https://d72cgtgi6hvvl.cloudfront.net/media/audio/250hz.mp3')
       ->render();
```

Add book attribute:

```
/**
 * @var OpenGraph $openGraph
 */
 $openGraph = Yii::$app->opengraph;

 $openGraph->getBook()
      ->setReleaseDate(new \DateTime('2011-10-10'))
      ->setTag(['Apple', 'New'])
      ->setAuthor(['http://umanskyi.com/profile.html'])
      ->setIsbn(1451648537)
      ->render();
```

Add music attribute:

```
/**
 * @var OpenGraph $openGraph
 */
 $openGraph = Yii::$app->opengraph;

 $openGraph->getMusic()
      ->setReleaseDate(new \DateTime('2016-01-16'))
      ->setDuration(236)
      ->setAttrAlbum([
          'album:track' => 2
      ])
      ->setMusician([
          'http://open.spotify.com/artist/1dfeR4HaWDbWqFHLkxsg1d',
          'http://open.spotify.com/artist/1dfeR4HaWDbWqFirlsag1d'
      ])
      ->render();
```

Add profile attribute:

```
/**
 * @var OpenGraph $openGraph
 */
 $openGraph = Yii::$app->opengraph;

 $openGraph->getProfile()
      ->setGender('Male')
      ->setFirstName('Vlad')
      ->setLastName('Umanskyi')
      ->setUsername('vlad.umanskyi')
      ->render();

```

Add video attribute:

```
/**
 * @var OpenGraph $openGraph
 */
 $openGraph = Yii::$app->opengraph;

 $openGraph->getVideo()
      ->setUrl('https://umanskyi.com/strobe/FlashMediaPlayback.swf')
      ->setAttributes([
          'width' => 450,
          'height' => 350,
          'secure_url' => 'https://umanskyi.com/strobe/FlashMediaPlayback.swf',
          'type' => 'application/x-shockwave-flash'
      ])
      ->setAdditionalAttributes([
          'tag' => 'train',
          'release_date' => '1980-10-02'
      ])
      ->render();
```

The current version also has a configuration **Twitter Card**

```
/**
 * @var OpenGraph $openGraph
 */
 $openGraph = Yii::$app->opengraph;

 $openGraph->useTwitterCard()
    ->setCard('summary')
    ->setSite('https://umanskyi.com')
    ->setCreator('Vlad Umanskyi')
    ->render();
```

If you want to add own configuration or override some tag, you must implement **umanskyi31\\opengraph\\Configuration** and add to Yii container. Some example you can find here **umanskyi31\\opengraph\\OpenGraphConfiguration**

---

If you have any [issue](https://github.com/vumanskyi/yii2-opengraph/issues) please let me know.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance80

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 95% 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 ~466 days

Recently: every ~623 days

Total

7

Last Release

103d ago

Major Versions

v1.1.2 → 2.0.02019-03-31

2.1.1 → 3.0.02022-12-27

PHP version history (5 changes)v1.1.2PHP &gt;=5.4.0

2.0.0PHP &gt;=7.1

2.1.0PHP &gt;=7.2

3.0.0PHP &gt;=8.0 || 7.4

3.0.1PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/b5f7b1a4890a3b862c192424ac424b6c61f5aed0c980485c9201ddec2c340472?d=identicon)[Vlad Umanskyi](/maintainers/Vlad%20Umanskyi)

---

Top Contributors

[![vumanskyi](https://avatars.githubusercontent.com/u/13002167?v=4)](https://github.com/vumanskyi "vumanskyi (76 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

facebookopengraphseoseotoolstwitteryii2yii2-componentyii2-frameworkfacebookyii2extensioncomponentseotwitter cardopengraphopen-graphVlad UmanskyiVladUmanskyi

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[kartik-v/yii2-social

Module containing useful widgets for Yii Framework 2.0 that integrates social functionalities from DISQUS, Facebook, Google etc.

91256.5k8](/packages/kartik-v-yii2-social)[jonom/silverstripe-share-care

Social media sharing previews and customisation for Silverstripe

2932.7k1](/packages/jonom-silverstripe-share-care)[mad-web/laravel-seoable

Easy to map your eloquent fields to seo properties

407.6k](/packages/mad-web-laravel-seoable)[daxslab/yii2-taggedview

Extension to help setup the standard HTML meta tags besides the ones defined by Opengraph and Twitter to contribute to website SEO

114.5k](/packages/daxslab-yii2-taggedview)[amirax/yii2-seo-tools

SEO tools for Yii 2 framework

131.1k](/packages/amirax-yii2-seo-tools)

PHPackages © 2026

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