Download the PHP package beyerz/open-graph-protocol-bundle without Composer
On this page you can find all versions of the php package beyerz/open-graph-protocol-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download beyerz/open-graph-protocol-bundle
More information about beyerz/open-graph-protocol-bundle
Files in beyerz/open-graph-protocol-bundle
Package open-graph-protocol-bundle
Short Description Integration for OpenGraph protocol and Symfony2
License MIT
Informations about the package open-graph-protocol-bundle
OpenGraphProtocolBundle
Easy Integration for Symfony2 projects requiring opengraph
The OpenGraphBundle enables easy integration for Symfony2 and twig views to incorporate the Open Graph Protocols
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
Installation
Composer
Application Kernel
Add OpenGraphBundle to the registerBundles()
method of your application kernel:
Config
Enable loading of the OGP service and setting default values by adding the following to
the application's config.yml
file:
A Base and facebook library are currently supported, but you can add as many libraries with as many default values that you like
Documentation
View
Include the OGP Metas in the head
tag of your layout.
With twig:
{% 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)
From your Controller
$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");