andrzejkupczyk/url-shortener

This package is abandoned and no longer maintained. No replacement package was suggested.

A simple library to generate shortened URLs

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

This package is auto-updated.

Last update: 2024-08-14 19:10:28 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

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"