emanueleminotto/embedly-service-provider

Embed.ly Service Provider for Silex

1.0.0 2015-02-05 00:25 UTC

This package is auto-updated.

Last update: 2024-03-28 05:44:36 UTC


README

Build Status SensioLabs Insight Coverage Status Scrutinizer Code Quality Total Downloads

An embed.ly service provider for Silex.

API: emanueleminotto.github.io/EmbedlyServiceProvider

Install

Install Silex using Composer.

Install the EmbedlyServiceProvider adding emanueleminotto/embedly-service-provider to your composer.json or from CLI:

$ composer require emanueleminotto/embedly-service-provider

Usage

Initialize it using register

use EmanueleMinotto\EmbedlyServiceProvider\EmbedlyServiceProvider;

$app->register(new EmbedlyServiceProvider(), array(
    'embedly.api_key' => 'xxx', // default null, optional
    'embedly.twig' => false, // default true, optional
));

From PHP

use Silex\Application;

$app->get('/get', function (Application $app) {
    $url = $app['request']->get('url');

    $data = $app['embedly']->oembed([
        'url' => $url,
    ]);

    return $app->json($data);
});

From Twig

Setting the option embedly.twig => true, if there's the Twig service provider, you'll be able to use the Twig extension provided by the Embedly library.