danielebuso/shortener

Laravel 7 local url shortener
2,812
Install
composer require danielebuso/shortener
Latest Version:1.0.3
PHP:^7.1
License:MIT
Last Updated:Jul 31, 2020
Links: GitHub  ·  Packagist
Maintainer: danielebuso

Laravel Link Shortener

Latest Version on Packagist Build Status Quality Score Total Downloads

Local link shortener for Laravel 7

Installation

You can install the package via composer:

composer require danielebuso/shortener

Publish the migration and migrate

php artisan vendor:publish --tag=migrations
php artisan migrate

Usage

$short_link = Shortener::shorten('https://example.com/my-very-long-link');

$short_link->short_url // Eg. https://myapp.com/l/JedO8TSC

Customize routing

To customize the link routing add the following to your routes and customize as you wish

Route::domain('mylink.com')->group(function () {
    Route::get('{short_link}', 'ShortLinkController@resolve')->name('short_link');
});

// Then in controller
$short_link->short_url // Eg. https://mylink.com/JedO8TSC

Configuration

To customize the config either use the environment variables or publish the configuration file

php artisan vendor:publish --tag=config
Config .env Default Description
link_length SHORTENER_LINK_LENGTH 8 Number of random characters used in link generation

Testing

composer test

Upcoming features

  • Custom validity (nbf, exp)
  • Link analitycs (times opened)
  • Real tests

Security

If you discover any security related issues, please email daniele@kodesire.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

waavi/url-shortener

Url Shortener for Laravel 5 with support for Google and Bitly drivers.

178,037 62
appsketch/adfly

An Adfly wrapper for Laravel 5 and 5.1.

434 1
mbarwick83/shorty

Google Url Shortener API Package for Laravel 5.1

204,507 31
appsketch/shortest

A shorte.st wrapper for Laravel 5 and 5.1.

40 0