A Laravel package to shorten urls

Overview

Laravel Short URL logo

Laravel Short Url Build Status StyleCI

Laravel Short Url is a package allowing you to shorten urls.

Installation

With composer

composer require gallib/laravel-short-url

then run

php artisan vendor:publish --provider="Gallib\ShortUrl\ShortUrlServiceProvider"
php artisan migrate

finally, paste ShortUrl::routes(); at the end of routes/web.php

Configuration

Laravel Short Url configuration file can be found on config/shorturl.php

  • blacklist : Allows to blacklist urls. Keywords can be either an url, a keyword or an extension

Advanced configuration

Instead of adding ShortUrl::routes(); you can call three separates methods:

  • ShortUrl::createRoutes(); to shorten urls
  • ShortUrl::manageRoutes(); to manage urls
  • ShortUrl::redirectRoute(); to redirect to the url

this allows you to add middlewares or prefix routes.

Migration Customization

If you are not going to use Short Url's default migrations, you should call the ShortUrl::ignoreMigrations(); method in the register method of your AppServiceProvider. You may export the default migrations using

php artisan vendor:publish --tag=shorturl-migrations

Nice!

Laravel short url is now set up on your homepage.

Credits

Comments
  • Update 2020_03_04_214540_add_user_id_to_urls.php

    Update 2020_03_04_214540_add_user_id_to_urls.php

    delete foreign key and change type of user_id, in this way is compatible with all laravel project. For example I use the uuid(char(36)) and it's not compatible with your library

    opened by apwebmaster 5
  • Proposal : Expiration date

    Proposal : Expiration date

    Functionnality proposal : Add an optional column expires_at. Then, a daily or weekly cron comes cleanup.

    Can be useful for temporary short links. For instance, if we send shortened url by mail to validate the email, it doesn't need to stay in time.

    enhancement 
    opened by Nuranto 3
  • Feature Request: Multi-User Support

    Feature Request: Multi-User Support

    Hi there! I very much like this simple and clean package and would love to use it. But currently my use case for a multi-user scenario prevents me, because a shortened url is not associated with the user, that authored this url.

    It would be just a small extension to add a user_id column to the url table. That way, we could filter to only show the urls authored by the current user, so that no urls are shown from other users and so that users cannot edit urls from other users.

    What do you think about this? If you do not consider this functionality to be implemented in the package, how could I extend the package myself to match my use case?

    enhancement 
    opened by erdmenchen 2
  • Laravel 8

    Laravel 8

    Problem 1
        - Root composer.json requires gallib/laravel-short-url ^1.8 -> satisfiable by gallib/laravel-short-url[1.8.0].
        - gallib/laravel-short-url 1.8.0 requires illuminate/database ^7.30.3|^8.22.1 -> found illuminate/database[v7.30.3, v7.30.4, 7.x-dev, v8.22.1, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require.
    
    opened by janczakb 1
  • Fix tests

    Fix tests

    On my local environment the model for User were not found, breaking most of test scenarios. The logs on travis show a missing fillable.

    I created and configured a stub for User model. Also added a new unit test for UrlParser that uses guzzle, which is mocked by all other tests.

    opened by pedrosancao 1
  • Allow custom migrations

    Allow custom migrations

    I had an issue with the mysql limit for key size (laravel/laravel#4774), but could not change the default size. Then I had to disable auto discover and replace the service provider.

    Laravel's Passport allows the use of custom migrations and I used the same approach.

    Also I assume it would fix PR #23 problems.

    opened by pedrosancao 1
  • bugfix #20

    bugfix #20

    I fixed this because a target error occurred in mysql.

    error details:

    Migrating: 2020_03_04_214540_add_user_id_to_urls
    
       Illuminate\Database\QueryException 
    
      SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `shorturl_urls` add constraint `shorturl_urls_user_id_foreign` foreign key (`user_id`) references `users` (`id`))
    
    opened by YasuakiHirano 1
  • Version bump for symfony/dom-crawler

    Version bump for symfony/dom-crawler

    symfony/http-kernel v5.1.0 requires "symfony/dom-crawler": "^4.4|^5.0"

    This is just a small version bump to prevent an issue installing the package.

    opened by ClaraLeigh 1
  • minimum stability issues

    minimum stability issues

    There are some depending issues of laravel-short-url package I have "laravel/framework": "5.7.*".

    I am getting issues while I run this command composer require gallib/laravel-short-url

    Problem 1 - gallib/laravel-short-url 1.4.2 requires symfony/dom-crawler ^4.2 -> satisfiable by symfony/dom-crawler[4.2.x-dev, 4.3.x-dev, v4.2.0, v4.2.0-BETA1, v4.2.0-BETA2, v4.2.0-RC1, v4.2.1, v4.2.2, v4.2.3] but these conflict with your requirements or minimum-stability. - gallib/laravel-short-url 1.4.1 requires illuminate/routing 5.6.* -> satisfiable by illuminate/routing[5.6.x-dev, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9] but these conflict with your requirements or minimum-stability. - gallib/laravel-short-url 1.4.0 requires illuminate/routing 5.6.* -> satisfiable by illuminate/routing[5.6.x-dev, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9] but these conflict with your requirements or minimum-stability. - Installation request for gallib/laravel-short-url ^1.4 -> satisfiable by gallib/laravel-short-url[1.4.0, 1.4.1, 1.4.2].

    opened by hiranipradeep 1
  • user_id relation

    user_id relation

    Laravel as a bigint(20) on the users table. Your Schema is wrong (now)

    $table->integer('user_id')->nullable()->unsigned()->after('expires_at');

    bug 
    opened by cdebattista 0
  • Functionnality : Create short url from Facade

    Functionnality : Create short url from Facade

    For the same use case as in #13

    If you're OK with adding those functionnalities, tell me if you want me to work on it, or if you prefer do it by yourself :)

    enhancement 
    opened by Nuranto 2
Releases(1.9.0)
Owner
Alain Pellaux
I'm a web developer.
Alain Pellaux
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
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
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
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

Marc Garcia Torrent 51 Dec 17, 2022
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

Pharaonic 2 Aug 7, 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
Laravel based API to shorten URLs and share them easily. Redirects to the real URL by entering a short URL generated by the API

URL Shortener Requirements: PHP 7.4 or above composer node / npm Installation clone the project from the Github repository, enter the project folder,

Julio Vergara 5 Nov 20, 2021
Michael Pratt 307 Dec 23, 2022
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 Laravel package for quickly adding .well-known URLs

A Laravel package for quickly adding .well-known URLs well-known is a Laravel package for quickly adding well-known locations (RFC8615) to a Laravel a

Kim Hallberg 2 Sep 13, 2022
A Laravel Gravatar package for retrieving gravatar image URLs or checking the existance of an image.

Gravatar for Laravel 5.x, 6, 7 and 8 Installation First, pull in the package through Composer via the command line: composer require creativeorange/gr

Creativeorange 477 Dec 1, 2022
Generate Laravel route URLs from JavaScript.

Laroute Laravel has some pretty sweet helper functions for generating urls/links and its auto-json-magic makes it building APIs super easy. It's my go

Aaron Lord 785 Dec 30, 2022
Easy multilingual urls and redirection support for the Laravel framework

Linguist - Multilingual urls and redirects for Laravel This package provides an easy multilingual urls and redirection support for the Laravel framewo

Tanel Tammik 189 Jul 18, 2022
Laravel 8 Project Restrict User Access From IP Addresses. prevent other ip address that want to access over secure api or urls.

block-ip-address-laravel Laravel 8 Project Restrict User Access From IP Addresses. prevent other ip address that want to access over secure api or url

Hasmukh Dharajiya 2 Mar 24, 2022
Create CloudFront signed URLs in Laravel 6+

Easy to use Laravel 6+ wrapper around the official AWS PHP SDK which allows to sign URLs to access Private Content through CloudFront CDN

Dreamonkey S.r.l. 45 Dec 31, 2022
A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

URLify for PHP A fast PHP slug generator and transliteration library, started as a PHP port of URLify.js from the Django project. Handles symbols from

Aband*nthecar 667 Dec 20, 2022
PHP library to parse urls from string input

Url highlight - PHP library to parse URLs from string input. Works with complex URLs, edge cases and encoded input. Features: Replace URLs in string b

Volodymyr Stelmakh 77 Sep 16, 2022