PHPackages                             sharelov/sharelov-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. sharelov/sharelov-shortener

ActiveLibrary

sharelov/sharelov-shortener
===========================

A configurable tool for shortening urls inside a Laravel project.

10.0.0(2y ago)39.0k[5 PRs](https://github.com/sharelov/sharelov-shortener/pulls)MITPHPPHP &gt;=7.2.5

Since Nov 18Pushed 1y ago6 watchersCompare

[ Source](https://github.com/sharelov/sharelov-shortener)[ Packagist](https://packagist.org/packages/sharelov/sharelov-shortener)[ RSS](/packages/sharelov-sharelov-shortener/feed)WikiDiscussions develop Synced 2d ago

READMEChangelogDependencies (4)Versions (25)Used By (0)

Sharelov : URL Shortener
------------------------

[](#sharelov--url-shortener)

developmaster[![StyleCI](https://camo.githubusercontent.com/790dcc8ca38ab6d1c2ab3b0f6ee98ec66286260bf5c1fef829abab894dd493ff/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131393431303232382f736869656c643f7374796c653d706c6173746963266272616e63683d646576656c6f70)](https://styleci.io/repos/119410228) [![CircleCI](https://camo.githubusercontent.com/89b52b982f60d1e952aead21dd38c6d4d8e10e76842e78498a41b7fa3dfaee80/68747470733a2f2f636972636c6563692e636f6d2f67682f53686172656c6f762f73686172656c6f762d73686f7274656e65722f747265652f646576656c6f702e7376673f7374796c653d737667)](https://circleci.com/gh/Sharelov/sharelov-shortener/tree/develop)[![StyleCI](https://camo.githubusercontent.com/6e6281f2e06026c92a1480c938619d6c9fb30c2d9b0ef63bfa4223ed99fc1c70/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131393431303232382f736869656c643f7374796c653d706c6173746963266272616e63683d6d6173746572)](https://styleci.io/repos/119410228) [![CircleCI](https://camo.githubusercontent.com/7b2fe0a221dc379eb84d469f3e350ff2aad48e5c5e9d01514dc09c249ace871e/68747470733a2f2f636972636c6563692e636f6d2f67682f53686172656c6f762f73686172656c6f762d73686f7274656e65722f747265652f6d61737465722e7376673f7374796c653d737667)](https://circleci.com/gh/Sharelov/sharelov-shortener/tree/master)Installation
============

[](#installation)

Require the package with Composer:

```
composer require sharelov/sharelov-shortener

```

After that, add the ServiceProvider to the providers array in `config/app.php`

```
Sharelov\Shortener\ShortenerServiceProvider::class,
```

You can optionally use the facade. If you decide to use it, add this to your aliases array in `config/app.php`:

```
'Shortener'=>Sharelov\Shortener\Facades\Shortener::class,
```

Then, run `composer dump-autoload`.

Afterwards, run `php artisan vendor:publish` to get the migration and config files.

Configuration
=============

[](#configuration)

The config file has important configuration you may want to look at and customize before running the migrations. If you haven't looked at it yet, you can customize the table name in the config file, so there will be no need to fiddle with the migration yourself. Once you make sure the table name will not cause conflicts with your existing tables, run `php artisan migrate` to install the table we use.

There is also the posibility to configure any of the following things:

- Hash length. (Default = 5)
- Maximum attempts at generating a unique hash. (Default = 3)
- Usage of Soft Deletes with your short links model. (Default = false)

There is ample documentation for each option in the config file. Feel free to trim it down after having looked it over and setting it up.

Usage
=====

[](#usage)

Use this route to decode a shortened URL, if the URL doesn't exist it will run `abort(404)` otherwise it will perform a redirect to the stored url asociated with that hash.

```
Route::get('/sh/{hash}',[
    'as'=>'shortener.get',
    'uses'=>'\Sharelov\Shortener\Controllers\LinksController@translateHash'
]);
```

Use this route to shorten a URL, if the URL already exists on the database it will return the hash code otherwise it will create a new URL|Hash tuple and it will return a json response with the hash and the url with the current domain indicating the status of the request.

The url receives the following query parameters:

Url to process by the shortener: `url=urltoshorten`

Expiration date for the link `expires_at=YYYY-MM-DD` (don't specify this in order to make the link not expire)

You can have an example of the requests on this postman collection: [PostMan Shortener Collection](https://www.getpostman.com/collections/ec779d63f1fe3af3bc6d)

```
Route::post('/sh',[
    'as'=>'shortener.store',
    'uses'=>'\Sharelov\Shortener\Controllers\LinksController@store'
]);
```

Succesfull json response

```
{
    "success": "true",
    "hash": "D7ZR6",
    "url": "http://sharelovdev.dev/sh/D7ZR6"
}
```

Unsuccessfull json response

```
{
    "success": "false",
    "hash": "",
    "url": ""
}
```

For using the facade don't forget to include it `use Shortener;` and then you can call the next methods:

Returns the hash for the url sended as a parameter and stores an object in the links table.

```
Shortener::make($url)
```

Returns the url corresponding to a hash string in the database.

```
Shortener::getUrlByHash($hash)
```

License
=======

[](#license)

This Laravel package is licensed with the [MIT License](https://choosealicense.com/licenses/mit/#).

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 62.1% 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 ~157 days

Recently: every ~69 days

Total

15

Last Release

898d ago

Major Versions

5.0 → 6.02022-10-17

6.0 → 7.02023-02-23

7.0 → 8.02023-05-02

8.0 → 9.02023-07-10

9.1.0 → 10.0.02023-11-28

PHP version history (3 changes)0.1.5PHP ^7.0

4.0PHP &gt;=7.1

6.0PHP &gt;=7.2.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d59de1c950132dbd69066a41f42abfe68ec9c71e1e0b2d38dfc33039be5d61e?d=identicon)[JLMorales](/maintainers/JLMorales)

---

Top Contributors

[![morales2k](https://avatars.githubusercontent.com/u/1074855?v=4)](https://github.com/morales2k "morales2k (77 commits)")[![sald19](https://avatars.githubusercontent.com/u/1674971?v=4)](https://github.com/sald19 "sald19 (27 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (8 commits)")[![keiwerkgvr](https://avatars.githubusercontent.com/u/3748506?v=4)](https://github.com/keiwerkgvr "keiwerkgvr (4 commits)")[![hosmelq](https://avatars.githubusercontent.com/u/1166143?v=4)](https://github.com/hosmelq "hosmelq (3 commits)")[![sharelov-eames](https://avatars.githubusercontent.com/u/16158600?v=4)](https://github.com/sharelov-eames "sharelov-eames (2 commits)")[![CarlosDuarte17](https://avatars.githubusercontent.com/u/63825298?v=4)](https://github.com/CarlosDuarte17 "CarlosDuarte17 (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[namu/wirechat

A Laravel Livewire messaging app for teams with private chats and group conversations.

54324.5k](/packages/namu-wirechat)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)

PHPackages © 2026

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