mactape / short-links
url shortener
Installs: 37
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.3
- laravel/framework: ^10.0|^11.0|^12.0
Requires (Dev)
- laravel/pint: ^1.21
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