PHP code example of pontedilana / open-graph-bundle
1. Go to this page and download the library: Download pontedilana/open-graph-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pontedilana / open-graph-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Pontedilana\OpenGraphBundle\PontedilanaOpenGraphBundle(),
);
}
namespace App\OpenGraph;
use App\Entity\BlogPost;
use Pontedilana\OpenGraphBundle\OpenGraph\DocumentWriterInterface;
use Pontedilana\OpenGraphBundle\Map\OpenGraphMapInterface;
use Opengraph\Opengraph;
class BlogPostMap implements OpenGraphMapInterface
{
/**
* @var BlogPost $data
*/
public function map(DocumentWriterInterface $document, $data)
{
$document->append(OpenGraph::OG_SITE_NAME, 'MyBlog');
$document->append(OpenGraph::OG_TYPE, OpenGraph::TYPE_ARTICLE);
$document->append(OpenGraph::OG_TITLE, $data->getTitle());
}
public function supports($data)
{
return $entity instanceof BlogPost;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.