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

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

fasaya/url-shortener
====================

A simple url shortener library for Laravel projects.

v1.0.0(2y ago)04[2 PRs](https://github.com/fasaya/url-shortener/pulls)MITPHPPHP ^8.0

Since Sep 10Pushed 2y ago1 watchersCompare

[ Source](https://github.com/fasaya/url-shortener)[ Packagist](https://packagist.org/packages/fasaya/url-shortener)[ RSS](/packages/fasaya-url-shortener/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (4)Used By (0)

Laravel Url Shortener
=====================

[](#laravel-url-shortener)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fd8baf7120244ee39107bec73820c2329e26d98bebd6e9d7b37e93ad03479d0b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6661736179612f75726c2d73686f7274656e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fasaya/url-shortener)[![Total Downloads](https://camo.githubusercontent.com/35f17026e77162d64bc067179bd3cc40fc8c240088ba9332b676359e2a60880d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6661736179612f75726c2d73686f7274656e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fasaya/url-shortener)

This is a package to shorten your url and manage your shorten urls

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

[](#installation)

You can install the package via composer:

```
composer require fasaya/url-shortener
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="url-shortener-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="url-shortener-config"
```

This is the contents of the published config file:

```
return [

    /**
     * Here you may specify the fully qualified class name of the user model class.
     */
    'user-model' => App\Models\User::class,

    /**
     * Maximum character length of shortened url slug
     */
    'min-length' => 6,

    /**
     * Maximum character length of shortened url slug
     */
    'max-length' => 10,

    /**
     * URL route for the shortened URL
     * Example
     *  'prefix' => '/l', // https://yourdomain.com/l/exampleString
     */
    'route' => [
        'prefix' => '/l',
        'middleware' => [
            // 'web',
        ],
    ],

    /**
     * Where should the admin route be?
     */
    'admin-route' => [
        'enabled' => true, // Should the admin routes be enabled?
        'as' => 'url-shortener-manager.',
        'prefix' => 'url-shortener-manager',
        'middleware' => [
            'web',
        ],
    ],

    /**
     * Admin Template
     * example
     * 'name' => 'layouts.app' for Default urlShortener use 'url-shortener::layouts.app'
     * 'section' => 'content' for Default urlShortener use 'content'
     * 'styles_section' => 'page_style' for Default urlShortener use 'page_style'
     * 'script_section' => 'page_script' for Default urlShortener use 'page_script'
     */
    'admin-template' => [
        'name' => 'url-shortener::layouts.app',
        'section' => 'content',
        'styles_section' => 'page_style',
        'script_section' => 'page_script',
    ],

    /**
     * Number of emails per page in the admin view
     */
    'links-per-page' => 30,

    /**
     * Date Format
     */
    'date-format' => 'm/d/Y g:i a',

];
```

Optionally, you can publish the url shortener manager dashboard views using

```
php artisan vendor:publish --tag="url-shortener-views"
```

Usage
-----

[](#usage)

```
use Fasaya\UrlShortener\UrlShortener;

// Add an expiration date (optional)
$expire_at = '2025-12-12 00:00:00'; // NULL for no expiration date

// Generate a random short URL
$link = UrlShortener::make('http://example.com', $expire_at)->short_url;

// Generate a custom short URL
$link = UrlShortener::make('http://example.com', 'custom-short-slug', $expire_at)->short_url;
```

Exceptions
----------

[](#exceptions)

The following exceptions may be thrown. You may add them to your ignore list in your exception handler, or handle them as you wish.

- Fasaya\\UrlShortener\\Exceptions\\UrlNotValidException - Not a valid URL.
- Fasaya\\UrlShortener\\Exceptions\\UrlExistsException - URL already exists and active.
- Fasaya\\UrlShortener\\Exceptions\\TriesLimitReachedException - Generating reached tries limit.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Fasaya](https://github.com/fasaya)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.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

Unknown

Total

1

Last Release

957d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ab5114d7b9f4a7203bf95c3f55b602d1385c3739f195ae49c758a002797e534?d=identicon)[fasaya](/maintainers/fasaya)

---

Top Contributors

[![fasaya](https://avatars.githubusercontent.com/u/53859179?v=4)](https://github.com/fasaya "fasaya (39 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[guava/calendar

Adds support for vkurko/calendar to Filament PHP.

298241.0k3](/packages/guava-calendar)[tonysm/rich-text-laravel

Integrates Trix content with Laravel

46577.8k1](/packages/tonysm-rich-text-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[spatie/laravel-screenshot

Take screenshots of web pages in Laravel apps

7615.9k2](/packages/spatie-laravel-screenshot)[joaopaulolndev/filament-world-clock

Show hours around the world by timezone

3111.9k](/packages/joaopaulolndev-filament-world-clock)[tonegabes/filament-better-options

Filament form components for better radio and checkbox options.

155.2k](/packages/tonegabes-filament-better-options)

PHPackages © 2026

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