Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

A simple library to generate shortened URLs

License

Notifications You must be signed in to change notification settings

andrzejkupczyk/url-shortener

Repository files navigation

URL Shortener

PHP requirement GitHub tag (latest SemVer) GitHub license Build status Code quality

A simple yet easily extendable library to generate shortened URLs using different providers.

Install

Via Composer

composer require andrzejkupczyk/url-shortener

Examples of use

Creating short URLs

$shortener = UrlShortener::bitly($apiUri, $apiKey);

$link = $shortener->shorten(new Url('https://github.com/andrzejkupczyk/url-shortener'));

print($link->shortUrl()); // http://bit.ly/2Dkm8SJ

Expanding shortened URLs

$shortener = UrlShortener::bitly($apiUri, $apiKey);

$link = $shortener->expand(new Url('http://bit.ly/2Dkm8SJ'));

print($link->longUrl()); // https://github.com/andrzejkupczyk/url-shortener

Supported providers

Shortening Expanding Branding
Bitly ✔️ ✔️ ✔️
Firebase Dynamic Links ✔️ ✔️
TinyURL ✔️

Laravel support

It is possible to use this package easily within a Laravel >=5.5 application (it is configured for discovery).

Artisan commands

url:expand {url}   Expand short URL
url:shorten {url}  Shorten long URL

Configuration (not required)

Publish and modify the configuration file:

php artisan vendor:publish --provider="WebGarden\UrlShortener\LaravelServiceProvider"