PHPackages                             marjose/url-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. marjose/url-shortener

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

marjose/url-shortener
=====================

This will generate a shorten URL based on the supplied URL

v1.0.0(4y ago)03MITPHPPHP ^8.0

Since Sep 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/MarJose123/url-shortener)[ Packagist](https://packagist.org/packages/marjose/url-shortener)[ Docs](https://github.com/whoami213/url-shortener)[ GitHub Sponsors](https://github.com/marjose)[ RSS](/packages/marjose-url-shortener/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (3)Used By (0)

URL Shortener
=============

[](#url-shortener)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7b29a19b29b3f30a484b1439d27845c518a7ba392816c8716e2059f7dd0f789f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61726a6f73652f75726c2d73686f7274656e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marjose/url-shortener)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ffc1d86d45eaabf67a726a0a5723db0805cbca0d5d645c1facfed12a085bb627/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f77686f616d693231332f75726c2d73686f7274656e65722f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/whoami213/url-shortener/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/864d0078a31b928f987f9af0fc1bdbb3680bcd76a57699505d2e61a0e675bd6c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f77686f616d693231332f75726c2d73686f7274656e65722f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/whoami213/url-shortener/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/673f955fa6ac23e9a960fb3c7a2a296aae1dcaaf63eeabeccb4589f0167136e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61726a6f73652f75726c2d73686f7274656e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marjose/url-shortener)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

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

[](#installation)

You can install the package via composer:

```
composer require marjose/UrlShortener
```

You can publish and run the migrations with:

```
php artisan vendor:publish --provider="Marjose\UrlShortener\UrlShortenerServiceProvider" --tag="UrlShortener-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Marjose\UrlShortener\UrlShortenerServiceProvider" --tag="UrlShortener-config"
```

This is the contents of the published config file:

```
return [
    'length' => 6, // Length of the string for shortening the URL
    'expiration' => 120, // minutes, 0 for no expiration
];
```

Usage
-----

[](#usage)

Generating the URL by using the default setting from the Config file.

```
use Marjose\UrlShortener\Facades\UrlShortener;
$response = UrlShortener::url('https://xxxx.xx/xxxx')->generate();
```

Generating the URL by adding expiration to the link.

```
use Marjose\UrlShortener\Facades\UrlShortener;
$response = UrlShortener::url('https://xxxx.xx/xxxx')->setExpiration(15)->generate();
```

Generating the URL by overriding the default setting from the Config file.

```
use Marjose\UrlShortener\Facades\UrlShortener;
$response = UrlShortener::url('https://xxxx.xx/xxxx')->setLength(5)->setExpiration(15)->generate();
```

Validate if the shorted URL is expired or not

```
use Marjose\UrlShortener\Facades\UrlShortener;
$response = UrlShortener::url('https://xxxx.xx/xxxx')->isExpired();

// This will return boolean or an exception if the supplied url is not found in the database
```

In your web.php route you can add a new route similar to this, so that you can capture and redirect to the original link once the like is validated by your controller.

```
Route::get('s/{url_key}',[YourControllerHere::class, 'YourControllerMethod']);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [MarJose](https://github.com/whoami213)

License
-------

[](#license)

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

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.9% 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

Unknown

Total

1

Last Release

1691d ago

### Community

Maintainers

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

---

Top Contributors

[![MarJose123](https://avatars.githubusercontent.com/u/18107626?v=4)](https://github.com/MarJose123 "MarJose123 (30 commits)")[![whoami213](https://avatars.githubusercontent.com/u/121368731?v=4)](https://github.com/whoami213 "whoami213 (8 commits)")

---

Tags

laravelphplaravelurl shortenermarjose

###  Code Quality

TestsPest

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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