Laravel based API to shorten URLs and share them easily. Redirects to the real URL by entering a short URL generated by the API

Overview

URL Shortener

Requirements:

  • PHP 7.4 or above
  • composer
  • node / npm

Installation

clone the project from the Github repository, enter the project folder, open a terminal inside the project folder and run:

  composer install
  npm install
  npm run dev

You need to create your .env file; inside the project folder run the following command:

  cp .env.example .env

then setup your db schema and db credentials into the .env file and create the database using your favorite method (phpMyAdmin, MySQL Workbench, etc).

NOTE: It is very important to put inside your .env file, in the APP_URL key, the url that you are using to execute this project. For example, if you use the web server that comes with Laravel, when running 'php artisan serve', that url will usually be 'http://127.0.0.1:8000'; however, if you use a web server like Xampp or Laragon and create a virtual host, you must put the url of the virtual host that you created.

After that you need to create the database tables and populate them with data by running:

  php artisan migrate --seed

After that, a default user is created with the following credentials:

  User:  admin
  Email: [email protected]
  Pswrd: password

API End-Points

http://{your-url}/api/v1/url/shortener

This will generate a short url that points to the provided real url, you need to send a GET request with a json body as follows:

  {
    "url" : "your-real-url-here"
  }

if succeed, the request will respond with a json body as follows:

  {
    "short_url" : "generated-short-url-here"
  }

http://{your-url}/api/v1/url/top

This will generate a Json array with the top 100 most visited Urls, you need to send a GET request without a body

http://{your-url}/api/v1/url/real

This will respond with the real Url that the provided short url points to, you need to send a GET request with a json body as follows:

  {
    "url" : "your-short-url-here"
  }

if succeed, the request will respond with a json body as follows:

  {
    "real_url" : "your-real-url-here"
  }

Acknowledgements

In this project I show how to work with:

  • Creating an API
  • Fetching an API
  • Livewire components
  • Livewire modals

Required and pending Improvements

  • To have separate and related tables since the same real URL could have several short URLs associated with it. This would also help in scalability of the application and in integration with other systems.
  • Create a token-based authentication for the API; this way, requests to the API could be limited in a free subscription model and have another paid subscription model with unlimited requests.
  • Create a pagination for the Top 100 URLs view.
You might also like...
A modern, powerful, and robust URL shortener
A modern, powerful, and robust URL shortener

🚡 A modern, minimalist, and lightweight URL shortener. Polr is an intrepid, self-hostable open-source link shortening web application with a robust A

Simpler Url Shortener for Laravel
Simpler Url Shortener for Laravel

Laravel Url Shortener Install composer require magarrent/laravel-url-shortener Run migrations: php artisan migrate Configuration If you want to config

Laravel URL Localization Manager - [ccTLD, sub-domain, sub-directory].
Laravel URL Localization Manager - [ccTLD, sub-domain, sub-directory].

Laravel URL Localization - (ccTLD, sub-domain, sub-directory). with Simple & Easy Helpers. Afrikaans Akan shqip አማርኛ العربية հայերեն অসমীয়া azərbayca

Purl is a simple Object Oriented URL manipulation library for PHP 7.2+

Purl Purl is a simple Object Oriented URL manipulation library for PHP 7.2+ Installation The suggested installation method is via composer: composer r

A simple URL shortener for PHP

Shorty Shorty is a simple URL shortener for PHP. Installation 1. Download and extract the files to your web directory. 2. Use the included database.sq

🔗 Your Own URL Shortener

Your Own URL Shortener YOURLS is a set of PHP scripts that will allow you to run Your Own URL Shortener, on your server. You'll have full control over

A URL shortener with various other utilities, backed by a custom lightweight framework.

da.gd What is da.gd? da.gd is both a URL shortener and a collection of quick-info tools written in PHP. It allows you to use curl (or any http client)

A simple but powerful URL shortener

UrlShorter 这是一个足够简洁的Url短网址生成器 This is a simple Url shorter. 兼容性 在PHP7.X 与 PHP 8.0 下测试通过 安装 step 1: git clone [email protected]:soxft/UrlShorter.git step

Enables the possibility generating sanitized URL parts from persisted patterns.

#Persisted sanitized pattern mapping What does it do? Enables the possibility generating sanitized URL parts from persisted patterns. How does it work

Owner
Julio Vergara
Senior Software Developer.....learning a little more every day
Julio Vergara
A laravel package for generating Bitly short URLs.

Laravel Bitly Package A laravel package for generating Bitly short URLs. For more information see Bitly Requirements Laravel 5.1 or later Installation

Wessel Strengholt 72 Nov 8, 2022
A PHP-based self-hosted URL shortener that can be used to serve shortened URLs under your own custom domain.

A PHP-based self-hosted URL shortener that can be used to serve shortened URLs under your own custom domain. Table of Contents Full documentation Dock

null 1.7k Dec 29, 2022
Um encurtador de URL's gratuito e Open source. Torne suas URL's um tanto pequenas forma rápida e gratuita

Slim Framework 4 Skeleton Application Use this skeleton application to quickly setup and start working on a new Slim Framework 4 application. This app

Kilderson Sena 30 Jun 30, 2022
Create and validate signed URLs with a limited lifetime

THIS PACKAGE IS NOT MAINTAINED ANYMORE. SIGNING URLS IS NOW PART OF LARAVEL: https://laravel-news.com/signed-routes Create secured URLs with a limited

Spatie 652 Dec 31, 2022
A simple PHP library to parse and manipulate URLs

Url is a simple library to ease creating and managing Urls in PHP.

The League of Extraordinary Packages 351 Dec 30, 2022
URL shortener web application based on the Laravel PHP Framework.

UrlHub Warning: UrlHub is still in development, constantly being optimized and isn't still stable enough to be used in production environments. Whatev

Kei 349 Jan 4, 2023
URL shortener web application based on the Laravel PHP Framework.

UrlHub Warning: UrlHub is still in development, constantly being optimized and isn't still stable enough to be used in production environments. Whatev

Kei 348 Dec 23, 2022
URL - link shortener based on sqlite

link-url-shortener url - link shortener based on sqlite.

Okin On 1 Nov 12, 2021
A fast and powerful URL Shortener built with Laravel, VueJS, and Tailwind CSS.

A fast and powerful URL Shortener built with Laravel, VueJS, and Tailwind CSS.

Devpri 53 Dec 25, 2022
:aerial_tramway: A modern, powerful, and robust URL shortener

?? A modern, minimalist, and lightweight URL shortener. Polr is an intrepid, self-hostable open-source link shortening web application with a robust A

Chaoyi Zha 4.6k Jan 1, 2023