2017 © Pedro Peláez
 

symfony-bundle open-graph-protocol-bundle

Integration for OpenGraph protocol and Symfony2

image

beyerz/open-graph-protocol-bundle

Integration for OpenGraph protocol and Symfony2

  • Thursday, December 22, 2016
  • by beyerz
  • Repository
  • 2 Watchers
  • 3 Stars
  • 4,998 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 5 Open issues
  • 4 Versions
  • 19 % Grown

The README.md

Packagist Minimum PHP Version Build Status, (*1)

OpenGraphProtocolBundle

Easy Integration for Symfony2 projects requiring opengraph, (*2)

The OpenGraphBundle enables easy integration for Symfony2 and twig views to incorporate the Open Graph Protocols, (*3)

Important Note: If you are using symfony version less than 2.8, please stay with build v1.0 as v2.0 may not work correctly due to symfony using traits for container awareness, (*4)

Installation

Composer

composer require beyerz/open-graph-protocol-bundle

Application Kernel

Add OpenGraphBundle to the registerBundles() method of your application kernel:, (*5)

public function registerBundles()
{
    return array(
        new Beyerz\OpenGraphProtocolBundle\OpenGraphProtocolBundle(),
    );
}

Config

Enable loading of the OGP service and setting default values by adding the following to the application's config.yml file:, (*6)

A Base and facebook library are currently supported, but you can add as many libraries with as many default values that you like, (*7)

#OGP Bundle
open_graph_protocol:
    libraries:
        base:
            class: Beyerz\OpenGraphProtocolBundle\Libraries\Base
            default_values:
                site_name: {{ default value for website name }}
                type: {{ default value for website type }}
                title: {{ default value for any page title }}
                url: {{ default value for any canonical url (acts as a fall back for bad pages) }}
                image: {{ default image for your site }}
                description: {{ default generic page description for your site }}
        facebook:
            class: Beyerz\OpenGraphProtocolBundle\Libraries\Facebook
            default_values: { app_id: {{ Your apps facebook id }} }

Documentation

View

Include the OGP Metas in the head tag of your layout., (*8)

With twig:, (*9)

{% block metas %}
        {{ ogp()|raw }}
{% endblock %}

Overriding Meta Values

Its common that you would want to change meta values like title, image, description etc... This is easily done from within your page page controller (or any where that has access to the service container), (*10)

From your Controller, (*11)

$ogp = $this->get('beyerz.ogp.open_graph');
$base = $ogp->get('base');
$base->addMeta('title', "My dynamic title");
$base->addMeta('url', $request->getSchemeAndHttpHost().$request->getRequestUri());
$base->addMeta('description', "My dynamic description");

Testing Tools

Facebook * https://developers.facebook.com/tools/debug/, (*12)

Twitter * https://cards-dev.twitter.com/validator, (*13)

The Versions

22/12 2016

dev-master

9999999-dev

Integration for OpenGraph protocol and Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 symfony opengraph og opengraph protocol open graph protocol facebook graph

22/12 2016

2.0.0

2.0.0.0

Integration for OpenGraph protocol and Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 symfony opengraph og opengraph protocol open graph protocol facebook graph

18/03 2015

dev-TwitterLibrary

dev-TwitterLibrary

Integration for OpenGraph protocol and Symfony2

  Sources   Download

MIT

The Requires

 

symfony2 symfony opengraph og opengraph protocol open graph protocol facebook graph

15/10 2014

v1.0

1.0.0.0

Integration for open graph protocol and Symfony2

  Sources   Download

MIT

The Requires

 

open graph protocol facebook graph