vumanskyi/php-open-graph-library

This is a simple PHP library which help to interact with Open Graph Protocol and Twitter Card

1.0.0 2021-02-04 22:25 UTC

This package is auto-updated.

Last update: 2022-11-21 21:48:41 UTC


README

banner-direct.svg

CircleCI StyleCI Total Downloads Latest Stable Version License: MIT

PHP Open Graph library

This is a library to help you configure and render Open Graph Protocol and Twitter Cards for your website.

Installation

The package could be installed with composer:

composer require vumanskyi/php-open-graph-library

Usage

use VU\OpenGraph\Render;
use VU\OpenGraph\PropertyConfiguration;
use VU\OpenGraph\Properties\Basic;

$render = new Render();
$configuration = new PropertyConfiguration($render);

$basic = new Basic($configuration);
$basic->setTitle('Test title')
    ->setDescription('Test description')
    ->setLocale('uk_UA')
    ->handle();

echo $basic->render();

And the result will be:

<meta property="og:title" content="Test title">
<meta property="og:description" content="Test description">
<meta property="og:locale" content="uk_UA">

Another types:

  • \VU\OpenGraph\Properties\Articles
  • \VU\OpenGraph\Properties\Audio
  • \VU\OpenGraph\Properties\Basic
  • \VU\OpenGraph\Properties\Book
  • \VU\OpenGraph\Properties\Image
  • \VU\OpenGraph\Properties\Profile
  • \VU\OpenGraph\Properties\Video
  • \VU\OpenGraph\Properties\TwitterCard

Unit testing

./vendor/bin/phpunit 

If you have any issues, please let me know