rezzza/shorty-bundle

Underwear for your long urls in Symfony

Installs: 8 100

Dependents: 0

Stars: 7

Watchers: 3

Forks: 3

Open Issues: 1

Language: PHP

1.1.0 2013-10-25 08:07 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.