This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
You can install the package via composer:
composer require marjose/UrlShortener
You can publish and run the migrations with:
php artisan vendor:publish --provider="Marjose\UrlShortener\UrlShortenerServiceProvider" --tag="UrlShortener-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --provider="Marjose\UrlShortener\UrlShortenerServiceProvider" --tag="UrlShortener-config"
This is the contents of the published config file:
return [
'length' => 6, // Length of the string for shortening the URL
'expiration' => 120, // minutes, 0 for no expiration
];
Generating the URL by using the default setting from the Config file.
use Marjose\UrlShortener\Facades\UrlShortener;
$response = UrlShortener::url('https://xxxx.xx/xxxx')->generate();
Generating the URL by adding expiration to the link.
use Marjose\UrlShortener\Facades\UrlShortener;
$response = UrlShortener::url('https://xxxx.xx/xxxx')->setExpiration(15)->generate();
Generating the URL by overriding the default setting from the Config file.
use Marjose\UrlShortener\Facades\UrlShortener;
$response = UrlShortener::url('https://xxxx.xx/xxxx')->setLength(5)->setExpiration(15)->generate();
Validate if the shorted URL is expired or not
use Marjose\UrlShortener\Facades\UrlShortener;
$response = UrlShortener::url('https://xxxx.xx/xxxx')->isExpired();
// This will return boolean or an exception if the supplied url is not found in the database
In your web.php route you can add a new route similar to this, so that you can capture and redirect to the original link once the like is validated by your controller.
Route::get('s/{url_key}',[YourControllerHere::class, 'YourControllerMethod']);
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.