PHPackages                             badmushroom/shorties - 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. badmushroom/shorties

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

badmushroom/shorties
====================

A simple URL shortner for Laravel applications.

05PHP

Since Jun 4Pushed 4w ago1 watchersCompare

[ Source](https://github.com/bad-mushroom/Shorties)[ Packagist](https://packagist.org/packages/badmushroom/shorties)[ RSS](/packages/badmushroom-shorties/feed)WikiDiscussions main Synced today

READMEChangelog (1)DependenciesVersions (1)Used By (0)

[![shorties_logo_transparent_512x512](https://private-user-images.githubusercontent.com/381203/430706967-1d1b3191-df78-4f2a-81d0-18332884090b.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODI5Mzk2NjMsIm5iZiI6MTc4MjkzOTM2MywicGF0aCI6Ii8zODEyMDMvNDMwNzA2OTY3LTFkMWIzMTkxLWRmNzgtNGYyYS04MWQwLTE4MzMyODg0MDkwYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNzAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDcwMVQyMDU2MDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zNTNlMzM4NDViNDVmZjZlNjM0NTE1ODcwZGMyOTY0YjBjYzk1N2I4YTc4ZTNhOGE0N2RhMmYxMjVjYzFlZDNiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.iGyPhqsWzixujyjfsCsw1VlW5rgFlSI2IZAbS05uLXM)](https://private-user-images.githubusercontent.com/381203/430706967-1d1b3191-df78-4f2a-81d0-18332884090b.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODI5Mzk2NjMsIm5iZiI6MTc4MjkzOTM2MywicGF0aCI6Ii8zODEyMDMvNDMwNzA2OTY3LTFkMWIzMTkxLWRmNzgtNGYyYS04MWQwLTE4MzMyODg0MDkwYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNzAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDcwMVQyMDU2MDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zNTNlMzM4NDViNDVmZjZlNjM0NTE1ODcwZGMyOTY0YjBjYzk1N2I4YTc4ZTNhOGE0N2RhMmYxMjVjYzFlZDNiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.iGyPhqsWzixujyjfsCsw1VlW5rgFlSI2IZAbS05uLXM)

Shorties
========

[](#shorties)

A Laravel package for generating, managing, and tracking short URLs — complete with analytics, customizable routing, view overrides, and pruning.

Features
--------

[](#features)

- Generate short URLs with custom or random codes
- Subdomain or path-based routing (configurable)
- Visitor analytics tracking (with fingerprinting, user agent, etc.)
- Optional view override for 404-style "link not found" page
- Artisan commands for creating and listing short links
- Configurable data retention with built-in Laravel pruning support

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

[](#installation)

```
composer require badmushroom/shorties
```

Publish config and views (optional):

```
php artisan vendor:publish --tag=shorties-config
php artisan vendor:publish --tag=shorties-views
```

Run migrations:

```
php artisan migrate
```

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

[](#configuration)

In `config/shorties.php`:

KeyDescription`route_mode``subdomain` or `path``subdomain`Subdomain to use for short links (e.g. `go`)`prefix`URI prefix to use if using `path` mode (e.g. `shorties`)`middleware`Middleware group applied to short URL routes (`web`, `api`, etc.)`track_analytics`Enable or disable tracking of short URL visits`analytics_retention_days`Number of days to keep analytics records before pruning### Example `.env` settings

[](#example-env-settings)

```
SHORTIES_ROUTE_MODE=path
SHORTIES_PATH=shorties
SHORTIES_TRACK_ANALYTICS=true
SHORTIES_ANALYTICS_RETENTION_DAYS=90
```

Routing
-------

[](#routing)

Shorties can handle links either by subdomain or by path:

### Subdomain-based

[](#subdomain-based)

```
https://go.example.com/my-short-code

```

```
'route_mode' => 'subdomain',
'subdomain' => 'go',
```

### Path-based

[](#path-based)

```
https://example.com/shorties/my-short-code

```

```
'route_mode' => 'path',
'prefix' => 'shorties',
```

Analytics Tracking
------------------

[](#analytics-tracking)

When `track_analytics` is enabled, Shorties dispatches a job on each visit that records:

- UUID of the URL
- Timestamp (`visited_at`)
- User agent
- Fingerprint (if provided)

Records are stored in `shorties_analytics`.

Pruning Old Analytics
---------------------

[](#pruning-old-analytics)

Shorties supports Laravel's [Model Pruning](https://laravel.com/docs/master/eloquent#pruning-models) to automatically remove old analytics data.

Add this to your scheduler:

```
$schedule->command('model:prune')->daily();
```

Configure retention via:

```
SHORTIES_ANALYTICS_RETENTION_DAYS=90
```

Or update `config/shorties.php`.

You can prune manually with:

```
php artisan model:prune --model="BadMushroom\Shorties\Models\Analytic"
```

Artisan Commands
----------------

[](#artisan-commands)

### Create a new short link

[](#create-a-new-short-link)

```
php artisan shorties:links:create
```

Interactively prompts for a long URL and optional short code.

### List short links

[](#list-short-links)

```
php artisan shorties:links
```

Displays a table of existing short codes, their URLs, visit counts, and creation timestamps.

Customizing the 404 View
------------------------

[](#customizing-the-404-view)

To show a custom "link not found" page, publish the default view:

```
php artisan vendor:publish --tag=shorties-views
```

Then edit:

```
resources/views/vendor/shorties/not-found.blade.php

```

Security &amp; Notes
--------------------

[](#security--notes)

- Uses UUIDs for both URL and analytic IDs
- Tracks analytics only if enabled via config
- Prunes old records based on configurable retention
- Routes are scoped to either a path or subdomain

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

---

Made by [Bad Mushroom](https://github.com/badmushroom)

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance61

Regular maintenance activity

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/381203?v=4)[Chris Sprague](/maintainers/bad-mushroom)[@bad-mushroom](https://github.com/bad-mushroom)

---

Top Contributors

[![bad-mushroom](https://avatars.githubusercontent.com/u/381203?v=4)](https://github.com/bad-mushroom "bad-mushroom (14 commits)")

### Embed Badge

![Health badge](/badges/badmushroom-shorties/health.svg)

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

###  Alternatives

[symfony/deprecation-contracts

A generic function and convention to trigger deprecation notices

2.1k884.9M725](/packages/symfony-deprecation-contracts)[thenextweb/passgenerator

A Laravel package to create Apple Wallet (old Passbook) compatible tickets.

302478.1k](/packages/thenextweb-passgenerator)[coolsam/flatpickr

Flatpickr input for Filamentphp

101262.5k2](/packages/coolsam-flatpickr)

PHPackages © 2026

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