A simple yet easily extendable library to generate shortened URLs using different providers.
Via Composer
composer require andrzejkupczyk/url-shortener
$shortener = UrlShortener::bitly($apiUri, $apiKey);
$link = $shortener->shorten(new Url('https://github.com/andrzejkupczyk/url-shortener'));
print($link->shortUrl()); // http://bit.ly/2Dkm8SJ
$shortener = UrlShortener::bitly($apiUri, $apiKey);
$link = $shortener->expand(new Url('http://bit.ly/2Dkm8SJ'));
print($link->longUrl()); // https://github.com/andrzejkupczyk/url-shortener
Shortening | Expanding | Branding | |
---|---|---|---|
Bitly | ✔️ | ✔️ | ✔️ |
Firebase Dynamic Links | ✔️ | ❌ | ✔️ |
TinyURL | ✔️ | ❌ | ❌ |
It is possible to use this package easily within a Laravel >=5.5 application (it is configured for discovery).
url:expand {url} Expand short URL
url:shorten {url} Shorten long URL
Publish and modify the configuration file:
php artisan vendor:publish --provider="WebGarden\UrlShortener\LaravelServiceProvider"