andrzejkupczyk/url-shortener

A simple library to generate shortened URLs

v3.0.0 2021-02-14 10:37 UTC

This package is auto-updated.

Last update: 2024-04-14 18:26:48 UTC


README

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"