mactape/short-links

url shortener

2.1.0 2025-04-02 16:52 UTC

This package is auto-updated.

Last update: 2025-04-02 16:52:43 UTC


README

Url Shortener

  • Laravel ^10.0, ^11.0 or ^12.0
  • PHP ^8.3

Installation

You can install the package via composer:

composer require mactape/short-links

You can publish and run the migrations with:

php artisan vendor:publish --tag="short-links-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="short-links-config"

configure in config/short-links.php

domain -> your application domain

expiration (default 12) integer in hours. Model will be pruned

Usage

create hash for url

$hash = ShortURL::generate('https://your-url-to-shorten');

now you can use like

return ShortURL::open($hash);

or navigate to https://your-application-domain/s/{hash}

Add to

\App\Console\Kernel schedule method if you use Laravel 10

$schedule->command('model:prune')->daily();

Or

Schedule::command('model:prune')->daily();

in your application's routes/console.php if you use Laravel >= 11