lib to work with OpenGraph

1.0.1 2018-06-13 07:49 UTC

This package is auto-updated.

Last update: 2023-09-28 00:03:46 UTC


Total Downloads Build Status

Lib to render open graph.


composer require sokil/php-social-opengraph

Basic Usage

// Open Graph
$openGraph = new \Sokil\OpenGraph;
  ->setTitle('The Matrix Revolutions')
  ->setDescription('The human city of Zion ...')

Then you can get opengraph as array. This may be useful to render meta tags in frameworks. Example for Yii:

$cs = Yii::app()->getClientScript();
foreach($openGraph->toArray() as $property => $content) {
    $cs->registerMetaTag($content, null, null, array(
        'property'  => $property,

You can render meta tags directly:

echo $openGraph->render();

// or just:
echo $openGraph;