PHPackages                             muhamed-didovic/shortener - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. muhamed-didovic/shortener

ActiveLibrary

muhamed-didovic/shortener
=========================

Shortener for Laravel with Vue.js SPA app

1.1.5(5y ago)034MITPHPPHP ^7.1.3CI failing

Since Oct 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/muhamed-didovic/shortener)[ Packagist](https://packagist.org/packages/muhamed-didovic/shortener)[ Docs](https://github.com/muhamed-didovic/shortener)[ RSS](/packages/muhamed-didovic-shortener/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (5)Dependencies (8)Versions (8)Used By (0)

shortener
=========

[](#shortener)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0cc6b843ce072326019156430becc081699b007035b8c1bf3940a98357c9c31e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7568616d65642d6469646f7669632f73686f7274656e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/muhamed-didovic/shortener)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/b78beda0ad57cfbd5e43f21441d067e6e51e5d5601a487a7196cc87ba5317334/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d7568616d65642d6469646f7669632f73686f7274656e65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/muhamed-didovic/shortener)[![Coverage Status](https://camo.githubusercontent.com/77439af10b8fb41cdaea22a7721bde0b8507ae138ec7c2def7b616b24ae931d4/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6d7568616d65642d6469646f7669632f73686f7274656e65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/muhamed-didovic/shortener/code-structure)[![Quality Score](https://camo.githubusercontent.com/6cd33da1d95d1f0e25dd7cf8dd6fef3959b1758019dfe2c763c7f6aa0746451a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d7568616d65642d6469646f7669632f73686f7274656e65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/muhamed-didovic/shortener)[![StyleCI](https://camo.githubusercontent.com/3d2ba994cc2b479b0c31832c5b598ea9db8626ffa812ccb6f981e951f137f69c/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3231343139333239302f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/214193290)[![Total Downloads](https://camo.githubusercontent.com/ccfa437a020a3158b0ab3e7427ecac55403b800bba96c21f973eba6c68b1224d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d7568616d65642d6469646f7669632f73686f7274656e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/muhamed-didovic/shortener)

This Laravel package allows you to shorten a URL, it comes also with frontend part which is done in vue.js and vuex. You can publish all files like: views, config, migrations for frontend you can publish js and css file and adjust them accordigly.

[![](https://raw.githubusercontent.com/muhamed-didovic/shortener/master/docs/usage.gif)](https://raw.githubusercontent.com/muhamed-didovic/shortener/master/docs/usage.gif)

**Basic Docs**

- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Frontend configuration](#frontend-configuration)
- [Routes](#routes)
- [Change log](#change-log)
- [Testing](#testing)
- [Contributing](#contributing)

Installation
------------

[](#installation)

Laravel Shortener requires [PHP](https://php.net) 7.1-7.4. This particular version supports Laravel 5.5-5.8, 6 and 7 only.

To get the latest version, simply require the project using [Composer](https://getcomposer.org):

Via Composer

```
$ composer require muhamed-didovic/shortener
```

Once installed, if you are NOT using automatic package discovery (Laravel 5.4 and below), then you need to register the `MuhamedDidovic\Shortener\ShortenerServiceProvider` service provider in your `config/app.php` like this:

```
'providers' => [
    ...
    MuhamedDidovic\Shortener\ShortenerServiceProvider::class,
]
```

You can also optionally alias our facade:

```
'aliases' => [
    ...
    'Shortener' => MuhamedDidovic\Shortener\Facades\Shortener::class,
]
```

Usage and next steps
--------------------

[](#usage-and-next-steps)

After you install the package, you need to run bellow commands in order to make it working, after that I'll give more info about configuration and usage.

First step, run command which is responsible for publishing js and css into `resources` and `public` folder.

```
php artisan vendor:publish --provider="MuhamedDidovic\Shortener\ShortenerServiceProvider" --tag="shortener::assets"
```

Second step, migrate DB and get the (`'links'`) table (this can be changed in (`'shortener.php'`) config file) where URLs will be stored:

```
php artisan migrate
```

Third step, check your (`'.env'`) file and check (`'APP_URL'`) option, this is used by default for shortend url, also you can change or override that in (`'shortener.php'`) config file

Fourth step, in order to serve view file and Vue.js all together, you'll need a route, by default that route is (`'{any?}'`), so just type any URL that you don't have in your routes

Configuration
-------------

[](#configuration)

Laravel Shortener package supports optional configuration.

You can publish the migration with:

```
php artisan vendor:publish --provider="MuhamedDidovic\Shortener\ShortenerServiceProvider" --tag="shortener::migrations"
```

After the migration has been published you can create the media-table by running the migrations:

```
php artisan migrate
```

You can publish the config-file with:

```
php artisan vendor:publish --provider="MuhamedDidovic\Shortener\ShortenerServiceProvider" --tag="shortener::config"
```

This is the contents of the published config file:

```
return [
    /*
     * Name of table where the links or the URLs should be stored
     */
    'table'  => 'links',

    /*
     * Url that should be used with the shortened string
     */
    'url'    => env('APP_URL', 'http://localhost'),

    /*
     * Routes used in the package
     */
    'routes' => [
        /*
         * Route used to store url with post request
         */
        'post_short_route' => 'short',

        /*
         * Route to get shortend url with get request
         */
        'get_short_route'  => 'short',

        /*
         * Route to get status of url provided with get request
         */
        'get_stats_route'  => 'stats',

        /*
         * Route to serve Vue instance
         */
        'vue_route'        => '{any?}',
    ]
];
```

Frontend Configuration
----------------------

[](#frontend-configuration)

### 1st step

[](#1st-step)

you need to publish frontend files(js, css and view) first:

```
php artisan vendor:publish --provider="MuhamedDidovic\Shortener\ShortenerServiceProvider" --tag="shortener::views"
php artisan vendor:publish --provider="MuhamedDidovic\Shortener\ShortenerServiceProvider" --tag="shortener::assets"
```

The first command above is for view file and it will be placed in `resources/views/vendor/` folder with the name: `shortener.blade.php`

It should be like this:

[![](https://raw.githubusercontent.com/muhamed-didovic/shortener/master/docs/view.png)](https://raw.githubusercontent.com/muhamed-didovic/shortener/master/docs/view.png)

Second command is publishing js and css into `resources` and `public` folder.

This is needed when we make changes to js or css files in `resources` folder, those files will be bundled and placed inside `public` folder

js and css files in `resources` folder should look like this:

[![](https://raw.githubusercontent.com/muhamed-didovic/shortener/master/docs/resources.png)](https://raw.githubusercontent.com/muhamed-didovic/shortener/master/docs/resources.png)

And the bundled files that are generated from `resources` folder will be placed in `public` folder:

[![](https://raw.githubusercontent.com/muhamed-didovic/shortener/master/docs/public.png)](https://raw.githubusercontent.com/muhamed-didovic/shortener/master/docs/public.png)

### 2nd step

[](#2nd-step)

you need to install npm dependencies in package.json file

```
npm install vue-template-compiler@2.6.10 clipboard@1.6.1 pluralize@4.0.0 vue@2.2.6 vue-axios@2.1.4 vue-router@2.3.1 vuex@2.3.1 --save-dev
```

### 3rd step

[](#3rd-step)

you need to add files to bundle in webpack.mix.js

```
mix.js('resources/js/shortener.js', 'public/js/shortener.js')
    .sass('resources/sass/shortener.scss', 'public/css/shortener.css');
```

### 4th step

[](#4th-step)

run the laravel mix, you can check package.json in `scripts` part for commands like

```
npm run dev
```

or watcher

```
npm run watch
```

Available routes and their explanations
---------------------------------------

[](#available-routes-and-their-explanations)

This package consists of 4 routes (you don't need to include them into your routes):

```
Route::group(
    [
        'namespace'  => 'MuhamedDidovic\Shortener\Controllers',
        'middleware' => 'MuhamedDidovic\Shortener\Middleware\ModifiesUrlRequestData',
    ],
    function () {
        //save url
        Route::post(config('shortener.routes.post_short_route'), 'LinkController@store');
        //get url
        Route::get(config('shortener.routes.get_short_route'), 'LinkController@show');
        //get stats
        Route::get(config('shortener.routes.get_stats_route'), 'LinkStatsController@show');
        //ROUTE for vue
        Route::get(config('shortener.routes.vue_route'), 'SinglePageController@show')->where('any', '.*');
    }
);
```

All endpoints are stored inside of shortener.php config file. First three routes are API based and return JSON results.

First two routes from web.php have (`'short'`) default endpoint option, first one is used to store and shorten URL, second is used to retrieve URL by code what we provide. Third route have (`'stats'`) default endpoint option and is used to get stats for particualar URL.

Last fourth route (`'{any?}'`) is default endpoint option and is used for Vue.js to show the view.

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Muhamed Didovic](https://github.com/muhamed-didovic)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~42 days

Recently: every ~0 days

Total

7

Last Release

2144d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d87e17a6168f5ae69bddb8d0983cd73b4a176816e33309a9e6bb5d97813a7ece?d=identicon)[muhamed-didovic](/maintainers/muhamed-didovic)

---

Top Contributors

[![muhamed-didovic](https://avatars.githubusercontent.com/u/3872717?v=4)](https://github.com/muhamed-didovic "muhamed-didovic (201 commits)")

---

Tags

laravellaravel-5-packagelaravel-applicationvuevuexlaravelshortenervuemuhamed-didovic

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/muhamed-didovic-shortener/health.svg)

```
[![Health](https://phpackages.com/badges/muhamed-didovic-shortener/health.svg)](https://phpackages.com/packages/muhamed-didovic-shortener)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

71510.9M66](/packages/laravel-mcp)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7825.3M18](/packages/akaunting-laravel-money)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
