rezzza/shorty-bundle

Underwear for your long urls in Symfony

Installs: 12 952

Dependents: 0

Suggesters: 0

Security: 0

Stars: 7

Watchers: 4

Forks: 3

Open Issues: 0

Type:symfony-bundle

v1.2.1 2015-12-18 08:53 UTC

This package is not auto-updated.

Last update: 2024-10-26 14:01:56 UTC


README

https://poser.pugx.org/rezzza/shorty-bundle/version.png https://travis-ci.org/rezzza/ShortyBundle.png?branch=master

Underwear for your long urls in Symfony.

Integration of Shorty library.

Installation

Use Composer to install: rezzza/shorty-bundle.

In your composer.json you should have:

{
    "require": {
        "rezzza/shorty-bundle": "2.0.*"
    }
}

Then update your AppKernel.php to register the bundle with:

new Rezzza\ShortyBundle\RezzzaShortyBundle()

Configuration

rezzza_shorty:
    default_provider: google
    providers:
        google:
            id: google
            key: ~
            http_adapter: ~ # default is Rezzza\Shorty\Http\CurlAdapter
        google2:
            id: google
            key: anotherkey
        bitly:
            id: bitly
            access_token: ~ #required
            http_adapter: ~ # default is Rezzza\Shorty\Http\CurlAdapter
        custom:
            id: my_custom_service
        chain:
            id: chain
            providers: [google, bitly, custom, google2]

Basic usage

$shorty = $this->container->get('rezzza.shorty.google');
// or
$shorty = $this->container->get('rezzza.shorty'); // will use default_provider.
try {
    $short  = $shorty->shorten('http://www.verylastroom.net');
    $long   = $shorty->expand($long);
} catch (\Rezzza\Shorty\Exception\Exception $e) {
    // oops ...
}

Exceptions

Exceptions directory.