PHPackages                             braid/shorten - 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. [Framework](/categories/framework)
4. /
5. braid/shorten

ActiveProject[Framework](/categories/framework)

braid/shorten
=============

A small PSR-7 and PSR-15 compliant headless url shortener.

1.0.1(8y ago)62MITPHP

Since Oct 24Pushed 8y ago2 watchersCompare

[ Source](https://github.com/wearebraid/shorten)[ Packagist](https://packagist.org/packages/braid/shorten)[ Docs](http://github.com/wearebraid/shorten)[ RSS](/packages/braid-shorten/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (5)Versions (3)Used By (0)

Shorten
=======

[](#shorten)

---

[![Build Status](https://camo.githubusercontent.com/ea3ad483d17dd91e108e18a1515a3d28f55d99d817450f14aa3e755db11120f0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f776561726562726169642f73686f7274656e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/wearebraid/shorten/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/38ce9753a21be497826841e51ce7172e910d01821a49cfc64929f694c064215c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f776561726562726169642f73686f7274656e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/wearebraid/shorten/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/daacd51d68d51be364a533e22b618341d1f973a459ee85b2ffde7841de477ab7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f776561726562726169642f73686f7274656e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/wearebraid/shorten/?branch=master)[![License](https://camo.githubusercontent.com/4762dbe7bd2eac174cb980805be959142ad390a95f486d15b00b18e9337223a7/68747470733a2f2f706f7365722e707567782e6f72672f62726169642f73686f7274656e2f6c6963656e7365)](https://packagist.org/packages/braid/shorten)

Need an easy to use custom URL shortener like bit.ly, t.co, goo.gl? Shorten is a simple, PSR-7 and PSR-15 compliant headless URL shortener made for developers like you.

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

[](#installation)

### Download

[](#download)

Shorten is a small micro application. It is easily installed with composer’s `create-project` command.

```
composer create-project braid/shorten your-shortener-name
```

### Configuration

[](#configuration)

Shorten comes with two example configuration files. To configure your instance, just copy these files:

```
cp config.example.php config.php
cp phinx.example.yml phinx.yml
```

#### config.php

[](#configphp)

Edit your newly created `config.php` as appropriate.

OptionDescription`base_url`You'll want to set your application’s `base_url` to the domain name you are using as a shortener ( for example).`api_secret`Choose a randomly generated key (&gt;32 bytes recommended). This will be your application’s `Bearer` token for api requests.`database`Shorten uses Laravel’s excellent [Eloquent ORM](https://laravel.com/docs/5.5/eloquent). Configure the database credentials here. MySQL/MariaDB is recommended for medium/high traffic, but a simple SQLite is also supported.Pro Tip: here’s a quick way to generate an api key:

```
php -r 'echo bin2hex(openssl_random_pseudo_bytes(32)) . "\n";'
```

#### phinx.yml

[](#phinxyml)

Shorten uses Rob Morgan’s [Phinx](https://phinx.org/) for database migrations. Phinx has its own configuration, but the values should be the same as your `config.php` `database` settings.

### Database

[](#database)

Once your configuration files have been created and updated, go ahead and create the database you specified in the above configuration file. Then simply run the migrations:

```
vendor/bin/phinx migrate
```

### Server

[](#server)

The last step is to simply point an http server or virtual host to the `public` directory. This documentation won't go into detail on how to setup Apache or nginx.

Api
---

[](#api)

Shorten comes with a simple API for creating, listing, and removing shortened urls.

MethodEndpointDescription`GET``/resources`List all shortened URLs currently stored.`POST``/resources`Creates a new URL. Must include a JSON body with a `url` attribute.`DELETE``/resources`Removes a shortened URL. Must include a JSON body with an `id` attribute.All api requests MUST include an `Authorization` header in the format:

```
Authorization: Bearer api_secret_here

```

The return format for redirect resources is JSON. Example:

```
{
  "id": 1,
  "hash": "ce24227c",
  "redirect_to": "http://www.google.com",
  "count": 0,
  "url": "http://bit.ly/ce24227c"
}
```

*Note: Yes `DELETE /resources/{id}` would be cleaner, but using simple strings allows for faster routing.*

Best practices
--------------

[](#best-practices)

Shorten is intended to be a simple set-and-forget service you can use internally at your organization or embed into the apps you build. Keep in mind it is a project and not a dependency, so you are free and encouraged to bolt on additional [PSR-15 middleware](https://github.com/middlewares/psr15-middlewares) if you want.

Sponsor
-------

[](#sponsor)

Shorten is written and maintained by [Braid LLC](https://www.wearebraid.com), and offered freely under an MIT license.

[![Braid LLC](https://camo.githubusercontent.com/f90d146e7cc164f8677e1b86cecf5f8c9a9a0887d1e68989705ef655ad359827/68747470733a2f2f6173736574732e776561726562726169642e636f6d2f7369672e706e67 "Written and maintained by Braid LLC")](https://www.wearebraid.com)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity64

Established project with proven stability

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 ~0 days

Total

2

Last Release

3124d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/db85c379f90173f437183b21df031e20997aaac69c7046fd927c2a3b57663d39?d=identicon)[justin-schroeder](/maintainers/justin-schroeder)

---

Tags

framework

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/braid-shorten/health.svg)

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

###  Alternatives

[defstudio/pest-plugin-laravel-expectations

A plugin to add laravel tailored expectations to Pest

98548.9k4](/packages/defstudio-pest-plugin-laravel-expectations)[vesp/core

Vesp core library to make backend simple

243.8k5](/packages/vesp-core)

PHPackages © 2026

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