emanueleminotto/embedly-service-provider

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Embed.ly Service Provider for Silex

1.0.0 2015-02-05 00:25 UTC

This package is auto-updated.

Last update: 2021-08-28 00:15:47 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.