magarrent / laravel-url-shortener
Simpler Url Shortener for Laravel
Fund package maintenance!
magarrent
Installs: 7 368
Dependents: 0
Suggesters: 0
Security: 0
Stars: 54
Watchers: 3
Forks: 4
Open Issues: 1
Type:package
Requires
- doctrine/dbal: ^3
- illuminate/support: ^7.0|^8.0|^9.0
Requires (Dev)
- orchestra/testbench: ^6.0
This package is auto-updated.
Last update: 2025-03-04 20:04:56 UTC
README
Install
composer require magarrent/laravel-url-shortener
Run migrations:
php artisan migrate
Configuration
If you want to configurate some package parameters, run vendor publish:
php artisan vendor:publish --provider="Magarrent\LaravelUrlShortener\LaravelUrlShortenerServiceProvider"
Change the Key Url length in the url-shortener.php
config file:
<?php return [ 'url_key_length' => 6, // http://test.test/X-random-key-length ];
Usage
Import the UrlShortener in your php file.
use Magarrent\LaravelUrlShortener\Models\UrlShortener;
Then you can use the Url shortener package to redirect internal and external links.
UrlShortener::generateShortUrl("https://www.kodio.tech")
UrlShortener::generateShortUrl("/my-next/local/page")
Ex. Redirection:
https://your.url/H8g9Jx => https://www.kodio.tech
You only have to send the Url To param to the UrlShortener model:
public static function generateShortUrl(String $toUrl): String
Roadmap
- Ask me for more features! You can buy me a coffe too :)
Changelog
1.0.4
- Added support for Laravel 9
- Fixed installation problem with migrations
1.0.2
- Add
getOriginalUrlFromKey
function to model - Added configuration for Url key length
1.0
- First version
Contributing
Please see CONTRIBUTING for details.
Credits
Security
If you discover any security-related issues, please email magarrent@gmail.com instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.