GithubHelp home page GithubHelp logo

shortener's Introduction

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 [email protected] instead of using the issue tracker.

Credits

License

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

shortener's People

Contributors

danielebuso avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.