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.

03PHP

Since Jun 8Pushed 11mo ago1 watchersCompare

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

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.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MTMyMDUsIm5iZiI6MTc3NTUxMjkwNSwicGF0aCI6Ii8zODEyMDMvNDMwNzA2OTY3LTFkMWIzMTkxLWRmNzgtNGYyYS04MWQwLTE4MzMyODg0MDkwYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwNlQyMjAxNDVaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05ZDFjYmE0ZTVmZmEyNzJmNmM1NTZlOTkwZGUzOGMyOTAxOGU4ZmJkMDI4ZWJkODdlNzJiMzRiOGYxZWYyNDhjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.tdfUlf8CK7VgmFx5olISbIvzVH6RyGhWwdw4bMvTX8Y)](https://private-user-images.githubusercontent.com/381203/430706967-1d1b3191-df78-4f2a-81d0-18332884090b.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MTMyMDUsIm5iZiI6MTc3NTUxMjkwNSwicGF0aCI6Ii8zODEyMDMvNDMwNzA2OTY3LTFkMWIzMTkxLWRmNzgtNGYyYS04MWQwLTE4MzMyODg0MDkwYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNDA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDQwNlQyMjAxNDVaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05ZDFjYmE0ZTVmZmEyNzJmNmM1NTZlOTkwZGUzOGMyOTAxOGU4ZmJkMDI4ZWJkODdlNzJiMzRiOGYxZWYyNDhjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.tdfUlf8CK7VgmFx5olISbIvzVH6RyGhWwdw4bMvTX8Y)

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`, you can configure:

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

```

Set in config:

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

### Path-based:

[](#path-based)

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

```

Set in config:

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

---

📊 Analytics Tracking
--------------------

[](#-analytics-tracking)

When `track_analytics` is enabled, Shorties will dispatch a job on each short link 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.

### Admin listing of short links:

[](#admin-listing-of-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
```

Edit the published file at:

```
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)

This package includes feature and unit tests. To run them:

```
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)
--------------------------------------------------------

[](#-made-by-bad-mushroom)

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity14

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://www.gravatar.com/avatar/f1a3173fa999f6045bcd8de4920098e50fbcf72e976175c9254cce938d9f0253?d=identicon)[bad-mushroom](/maintainers/bad-mushroom)

---

Top Contributors

[![bad-mushroom](https://avatars.githubusercontent.com/u/381203?v=4)](https://github.com/bad-mushroom "bad-mushroom (5 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)
```

PHPackages © 2026

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