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

AbandonedArchivedYii2-extension

dragonjet/yii2-opengraph
========================

Open Graph implementation for Yii 2

1817.0k↓50%12[1 issues](https://github.com/dragonjet/yii2-opengraph/issues)1PHP

Since Feb 19Pushed 11y ago4 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (1)

Open Graph for Yii 2.x
======================

[](#open-graph-for-yii-2x)

Open Graph implementation for Yii 2 which adds valid meta tags to your HTML output.

Configuration
-------------

[](#configuration)

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

```

Usage
-----

[](#usage)

The following codes must be used on controller actions before rendering the view.

### Usage via Object

[](#usage-via-object)

```
Yii::$app->opengraph->title = 'My_Article';
Yii::$app->opengraph->description = 'My_Article_Description';
Yii::$app->opengraph->image = 'http://image.for.my/article';
return $this->render('My_View_Name');

```

### Usage via Array

[](#usage-via-array)

```
Yii::$app->opengraph->set([
	'title' => 'My_Article',
	'description' => 'My_Article_Description',
	'image' => 'http://image.for.my/article',
]);
return $this->render('My_View_Name');

```

### Twitter Cards

[](#twitter-cards)

```
Yii::$app->opengraph->title = 'My_Article';
Yii::$app->opengraph->description = 'My_Article_Description';
Yii::$app->opengraph->image = 'http://image.for.my/article';
Yii::$app->opengraph->twitter->card = 'summary';
Yii::$app->opengraph->twitter->site = 'My_Site_Twitter_Username';
Yii::$app->opengraph->twitter->creator = 'Author_Username';
return $this->render('My_View_Name');

```

or

```
Yii::$app->opengraph->set([
	'title' => 'My_Article',
	'description' => 'My_Article_Description',
	'image' => 'http://image.for.my/article',
	'twitter' => [
		'card' => 'summary',
		'site' => 'My_Site_Twitter_Username',
		'creator' => 'Author_Username',
	],
]);
return $this->render('My_View_Name');

```

Available Properties
--------------------

[](#available-properties)

#### Title

[](#title)

`Yii::$app->opengraph->title`

This is the title that shows up on social sharing. In contrast to the view title, this should be simpler and should not contain your branding for best practice, as mentioned on the *Facebook Sharing Guidelines*:

- "*The title of your article, excluding any branding.*"
- "*The title should not have branding or extraneous information.*"

e.g. "*MySite.com - Blog - Hello world!*" should just be "*Hello World!*"

#### Site Name

[](#site-name)

`Yii::$app->opengraph->site_name`

\[**Automatic**\] Your website's name. You do not need to specify this on every controller action if you have an application `name` in your Yii config:

```
return [
    'id' => 'yiiappid',
	'name' => 'My Website',
    //....
]

```

#### URL

[](#url)

`Yii::$app->opengraph->url`

\[**Automatic**\] This is automatically prefilled with the current URL. You do not need to specify this on every controller action.

#### Description

[](#description)

`Yii::$app->opengraph->description`

Description of the current page. Optional but recommended for best results in social sharing.

#### Object Type

[](#object-type)

`Yii::$app->opengraph->type`

The type of object this page will appear on social media. Defaults to `article`.

#### Locale

[](#locale)

`Yii::$app->opengraph->locale`

\[**Automatic**\] This is the locale (language) of the open graph object. This defaults to your Yii application language.

#### Image

[](#image)

`Yii::$app->opengraph->image`

Image for the graph object. This is highly recommended for best results when shared onto the social media. For best results in Facebook, make this at least `600x315px`

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/fdad7d63eebc7566e01282a1427d1dda88412f0d620b8bcda0b136f232340299?d=identicon)[dragonjet](/maintainers/dragonjet)

---

Top Contributors

[![dragonjet](https://avatars.githubusercontent.com/u/557312?v=4)](https://github.com/dragonjet "dragonjet (11 commits)")

### Embed Badge

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

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

PHPackages © 2026

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