Skip to content
Shorten URL's using your own domain
Branch: master
Clone or download
Latest commit 30350ec Jun 6, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config Service provider changes and config file moved May 31, 2019
src Fixing facade Jun 6, 2019
LICENSE.MD Added license May 30, 2019
composer.json URLShortener facade alias fix Jun 6, 2019
readme.md Changes in README file May 31, 2019

readme.md

License: MIT

URL Shortener

Shorten URL's using your own domain

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Laravel 5.8+ (Not tested in previous versions)

Installing

  1. Download it into your Laravel app using composer
composer require cedaesca/urlshortener
  1. Publish the packages files
php artisan vendor:publish
  1. Run the migrations.
php artisan migrate

Customizing the URL's code length

  1. Go to the config file located on config/cedaesca/URLShortener.php

  2. Change the length value for that of your preference.

URLShortener Facade

You have to add the URLShortener facade to your controller:

use cedaesca\URLShortener\Facades\URLShortener;

Then you'll have access to the create and redirect methods.

Shorten URL's

Use the create static method to shorten a given URL. This method receives the request as argument and returns an instance of the model if was successfully created or false if not:

URLShortener::create(Request $request);

Redirecting users

Use the redirectstatic method to redirect users to the target url's. This method receives the URL code parameter as argument.

Route::get('/r/{code}', 'UrlShortenerController@redirect')->name('rthis');
return URLShortener::redirect($code);

Default redirect

If the code given as argument is invalid, the redirect method will redirect the user to a default route. Change this from the config file.

  1. Go to the config file located on config/cedaesca/URLShortener.php

  2. Change the defaultRedirect value for that of your preference.

You can’t perform that action at this time.