This bundle integrates the Essence library (an oEmbed library) into Symfony 2.
Add the bundle to composer.json
{
"require": {
"kayue/kayue-essence-bundle": "dev-master"
}
}
Update Composer dependency:
composer update kayue/kayue-essence-bundle
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Kayue\EssenceBundle\KayueEssenceBundle(),
);
// ...
}
No configuration is required. However you should change the cache driver to apc
if your server support it. Default cache driver is array
kayue_essence:
cache_driver: apc
<?php
class WelcomeController extends Controller
{
public function indexAction()
{
$essence = $this->get('kayue_essence');
$media = $essence->embed('http://www.youtube.com/watch?v=39e3KYAmXK4');
$media->title; // return the video title "Bill Hicks - Revelations (1993)"
}
}
Essence can replace any embeddable URL in a text by informations about it.
{{ 'Some random text plus http://www.youtube.com/watch?v=39e3KYAmXK4'|essence_replace }}
You can retrieve video informations in just one line.
{{ essence_embed('http://www.youtube.com/watch?v=39e3KYAmXK4').html }}
With max width:
{{ essence_embed('http://www.youtube.com/watch?v=39e3KYAmXK4', {'maxwidth': 100}).html }}