PHPackages                             floor12/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. floor12/yii2-opengraph

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

floor12/yii2-opengraph
======================

Open Graph implementation for Yii 2

0.1.0(8y ago)016MITPHP

Since Feb 10Pushed 6y ago1 watchersCompare

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

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

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

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

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

3012d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8dc98d778cb18db41a1e5b9df722c56f65f655de44fe0d581484cd8dea31b928?d=identicon)[floor12](/maintainers/floor12)

---

Top Contributors

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

---

Tags

facebookyii2extensionopen-graph

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/floor12-yii2-opengraph/health.svg)](https://phpackages.com/packages/floor12-yii2-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)[umanskyi31/opengraph

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

119.7k](/packages/umanskyi31-opengraph)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

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