PHPackages                             binary-cats/laravel-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. binary-cats/laravel-url-shortener

ActiveLibrary

binary-cats/laravel-url-shortener
=================================

Powerful URL shortening tools in Laravel

8.0.0(5y ago)04.8k2MITPHPPHP &gt;=5.6.0

Since Apr 16Pushed 5y agoCompare

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

READMEChangelog (1)Dependencies (7)Versions (9)Used By (0)

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

[](#url-shortener-for-laravel)

Powerful URL shortening tools for your Laravel

 [![](https://camo.githubusercontent.com/fd915da7472053ee21c648385e5f7733a6c7287e0d64d0c36ac16e2f472f1fe4/68747470733a2f2f706f7365722e707567782e6f72672f62696e6172792d636174732f6c61726176656c2d75726c2d73686f7274656e65722f646f776e6c6f616473)](https://packagist.org/packages/binary-cats/laravel-url-shortener) [![](https://camo.githubusercontent.com/2f2070dc1172570fe394f821f27079b4f0b3d08e3e60a13506768aaf5e6e150c/68747470733a2f2f706f7365722e707567782e6f72672f62696e6172792d636174732f6c61726176656c2d75726c2d73686f7274656e65722f76657273696f6e)](https://packagist.org/packages/binary-cats/laravel-url-shortener) [![](https://camo.githubusercontent.com/03a424d5f8b2204de31d3eb0a7fd4222210233b86475700e4c9a521ac8a5a29f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62696e6172792d636174732f6c61726176656c2d75726c2d73686f7274656e65722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/binary-cats/laravel-url-shortener/) [![](https://camo.githubusercontent.com/8e488ba6a37ff90aac2c298af5ad987552cb48d9a894db32f5838f40975aa7e9/68747470733a2f2f706f7365722e707567782e6f72672f62696e6172792d636174732f6c61726176656c2d75726c2d73686f7274656e65722f6c6963656e7365)](https://packagist.org/packages/binary-cats/laravel-url-shortener)

- [Installation](#installation)
    - [Requirements](#requirements)
    - [Laravel 8+](#laravel-8)
    - [Laravel 5.5+](#laravel-55)
    - [Laravel 5.1-5.4](#laravel-51-54)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Changing the driver](#changing-the-driver)
    - [Adding your own drivers](#adding-your-own-drivers)
- [Available drivers](#available-drivers)
    - [Bit.ly](#bitly)
    - [Firebase Dynamic Links](#firebase-dynamic-links)
    - [Is.gd](#isgd--vgd)
    - [Ouo.io](#ouoio)
    - [Polr](#polr)
    - [Shorte.st](#shortest)
    - [TinyURL](#tinyurl)
    - [V.gd](#isgd--vgd)
- [Changelog](#changelog)
- [Security](#security)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

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

[](#installation)

You can easily install this package using Composer, by running the following command:

```
composer require binary-cats/laravel-url-shortener
```

### Requirements

[](#requirements)

This package has the following requirements:

- PHP 7.1 or higher
- Laravel 5.1 or higher

### Laravel 8+

[](#laravel-8)

If you use Laravel 8 you must have PHP 7.3 or higher (which is a root laravel requirment)

### Laravel 5.5+

[](#laravel-55)

If you use Laravel 5.5 or higher, that's it. You can now use the package, continue to the [usage](#usage) section.

### Laravel 5.1-5.4

[](#laravel-51-54)

If you're using an older version of Laravel, register the package's service provider to your application. You can do this by adding the following line to your `config/app.php` file:

```
'providers' => [
   ...
   BinaryCats\UrlShortener\UrlShortenerServiceProvider::class,
   ...
],
```

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

[](#configuration)

If you want to change the default configuration, you can publish it with:

```
php artisan vendor:publish --provider=BinaryCats\\UrlShortener\\UrlShortenerServiceProvider
```

The package will expose the following config file:

```
return [

    'default' => env('URL_SHORTENER_DRIVER', 'tiny_url'),

    'shorteners' => [

        'bit_ly' => [
            'driver' => 'bit_ly',
            'domain' => env('URL_SHORTENER_PREFIX', 'bit.ly'),
            'token' => env('URL_SHORTENER_API_TOKEN'),
        ],

        'firebase' => [
            'driver' => 'firebase',
            'prefix' => env('URL_SHORTENER_PREFIX'),
            'token' => env('URL_SHORTENER_API_TOKEN'),
            'suffix' => env('URL_SHORTENER_STRATEGY', 'UNGUESSABLE'),
        ],

        'is_gd' => [
            'driver' => 'is_gd',
            'base_uri' => 'https://is.gd',
            'statistics' => env('URL_SHORTENER_ANALYTICS', false),
        ],

        'ouo_io' => [
            'driver' => 'ouo_io',
            'token' => env('URL_SHORTENER_API_TOKEN'),
        ],

        'polr' => [
            'driver' => 'polr',
            'prefix' => env('URL_SHORTENER_PREFIX'),
            'token' => env('URL_SHORTENER_API_TOKEN'),
        ],

        'shorte_st' => [
            'driver' => 'shorte_st',
            'token' => env('URL_SHORTENER_API_TOKEN'),
        ],

        'tiny_url' => [
            'driver' => 'tiny_url',
        ],

        'v_gd' => [
            'driver' => 'is_gd',
            'base_uri' => 'https://v.gd',
            'statistics' => env('URL_SHORTENER_ANALYTICS', false),
        ],
    ],
];
```

Below is the full list of `.env` values to configure:

```
#-------------------------
# Services:  Url Shortener
#
#-------------------------
URL_SHORTENER_DRIVER=tiny_url
URL_SHORTENER_PREFIX=
URL_SHORTENER_API_TOKEN=
URL_SHORTENER_STRATEGY=
URL_SHORTENER_ANALYTICS=
```

Usage
-----

[](#usage)

The shortener can be retrieved from the container in two ways:

```
$shortener = app('url.shortener');
// or...
$shortener = url()->shortener();
```

Once you have an instance of the shortener, you can shorten your URLs:

```
// This will return your shortened URL as a string
$shortener->shorten(...);

// This will return a promise which will resolve to your shortened URL
$shortener->shortenAsync(...);

// You can also call shortening from Laravel's url component directly
url()->shorten(...);

// or...
app('url')->shorten(...);

// or even...
app('url.shortener')->shorten(...);
```

This package relies on Guzzle's promise library for its asynchronous shortening, read their [documentation](https://github.com/guzzle/promises) for more information.

You can also use dependency injection to inject the shortener into a method:

```
class MyController extends Controller
{
    public function myFunction(ShortenerManager $shortener)
    {
        $shortener->shorten(...);
    }
}
```

The shortener exposes the following methods:

MethodDescription`shorten`Shorten the given URL`shortenAsync`Shorten the given URL asynchronously`driver`Retrieve a driver (e.g. `tiny_url`)`extend`Register your own driver### Changing the driver

[](#changing-the-driver)

You can change the default driver by setting `URL_SHORTENER_DRIVER={driver}` in your environment file or publishing the config file and changing it directly.

### Adding your own drivers

[](#adding-your-own-drivers)

Much like all of Laravel, you can add your own drivers for this package. You can do this by adding the following code to `boot` method of your `AppServiceProvider`.

```
use BinaryCats\UrlShortener\UrlShortenerManager;

public function boot(UrlShortenerManager $shorteners)
{
    $shorteners->extend('local', function ($app, $config) {
        return new LocalUrlShortener($app, $config);
    });
}
```

Once you have registered your driver you can call it just like any other driver.

If you wrote a custom driver that others might find useful (such as a public online shortener service), please consider adding it to the package via a pull request.

Available drivers
-----------------

[](#available-drivers)

Below is a list of available drivers along with their individual specs:

ServiceDriver nameSince versionAnalyticsMonetization[Bit.ly](#bitly)`bit_ly`0.1.0yesno[Firebase Dynamic Links](#firebase-dynamic-links)`firebase`0.2.0yesno[Is.gd](#isgd--vgd)`is_gd`0.2.0yesno[Ouo.io](#ouoio)`ouo_io`0.2.0yesyes[Polr](#polr)`polr`0.3.0yesno[Shorte.st](#shortest)`shorte_st`0.1.0yesyes[TinyURL](#tinyurl)`tiny_url`0.1.0nono[V.gd](#isgd--vgd)`is_gd`0.2.0yesno### Bit.ly

[](#bitly)

[website](https://bit.ly)

This driver runs on Bit.ly's API and currently only supports API version 4. The API requires an access token and currently only *generic access tokens* are supported. You can retrieve such tokens from your Bit.ly profile. If you have a paid Bit.ly account you will also be able to set the domain for your shortened URLs.

VariableDescription`URL_SHORTENER_API_TOKEN`Your Bit.ly API token`URL_SHORTENER_PREFIX`Your short URL domain### Firebase Dynamic Links

[](#firebase-dynamic-links)

[website](https://firebase.google.com/)

This driver runs on Firebase's API. The API requires an access token, a URI prefix and a suffix. You can access these information on you firebase console. The token accessible under the project settings as "Web API Key" and the prefixes can be defined and accessed under the Dynamic Links menu.

The suffix can have the value `SHORT` or `UNGUESSABLE`.

> **IMPORTANT!** Links created via the API are not visible in the Firebase console. They are only accessible via the [Analytics REST API](https://firebase.google.com/docs/reference/dynamic-links/analytics).

VariableDescriptionDefault`URL_SHORTENER_API_TOKEN`Your Firebase API token`URL_SHORTENER_PREFIX`Your URL prefix`URL_SHORTENER_STRATEGY`The path component creation method`UNGUESSABLE`### Is.gd / V.gd

[](#isgd--vgd)

[website](https://is.gd)

This driver supports [is.gd](https://is.gd) and [v.gd](https://v.gd) trough their respective APIs. When link previews are enabled v.gd will be used, otherwise is.gd will be used.

VariableDescription`URL_SHORTENER_ANALYTICS`Enable or disable statistics### Ouo.io

[](#ouoio)

[website](https://ouo.io)

This driver uses the Ouo.io API and requires an access token. The API allows for URL monetization via advertisements and provides analytics via its dashboard.

VariableDescription`URL_SHORTENER_API_TOKEN`Your Ouo.io API token### Polr

[](#polr)

[website](https://github.com/cydrobolt/polr/)

This driver uses the Polr API. The API requires an access token and a URI prefix.

VariableDescription`URL_SHORTENER_API_TOKEN`Your Polr API token`URL_SHORTENER_PREFIX`Your URL prefix### Shorte.st

[](#shortest)

[website](https://shorte.st)

This driver uses the Shorte.st API, which requires an access token. This API supports monetization of your URLs and can give you insight into your traffic via its dashboard.

VariableDescription`URL_SHORTENER_API_TOKEN`Your Shorte.st API token### TinyURL

[](#tinyurl)

[website](http://tinyurl.com)

This driver runs on the TinyURL API, which requires no additional setup. This driver is the package default.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has been changed in recent versions.

Security
--------

[](#security)

If you discover any security related issues, please email one of the authors instead of using the issue tracker. You can find the author emails in the [composer.json](composer.json).

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

[](#contributing)

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

Credits
-------

[](#credits)

This is a port from the original [LaraCraft's Url Shortener](https://github.com/BinaryCats/laravel-url-shortener).

- [Choraimy Kroonstuiver](https://github.com/axlon)
- [László Görög](https://github.com/nerg4l)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

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

Every ~77 days

Recently: every ~99 days

Total

8

Last Release

2040d ago

Major Versions

v0.4.0 → 8.0.02020-10-10

PHP version history (2 changes)v0.1.0PHP ^7.1

8.0.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ebb48367388b4368b14cca42714bb13002d7414d9dc8da19c5490ef65c059719?d=identicon)[cyrill.kalita@gmail.com](/maintainers/cyrill.kalita@gmail.com)

---

Top Contributors

[![axlon](https://avatars.githubusercontent.com/u/3661474?v=4)](https://github.com/axlon "axlon (27 commits)")[![cyrillkalita](https://avatars.githubusercontent.com/u/2401848?v=4)](https://github.com/cyrillkalita "cyrillkalita (4 commits)")[![nerg4l](https://avatars.githubusercontent.com/u/4079392?v=4)](https://github.com/nerg4l "nerg4l (4 commits)")[![irazasyed](https://avatars.githubusercontent.com/u/1915268?v=4)](https://github.com/irazasyed "irazasyed (1 commits)")

---

Tags

urllaravellumenbitlyshortenerbinary-catsshorteningtinyurlshorte.st

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/binary-cats-laravel-url-shortener/health.svg)

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

###  Alternatives

[laracrafts/laravel-url-shortener

Powerful URL shortening tools in Laravel

97110.7k](/packages/laracrafts-laravel-url-shortener)[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

3.3k4.5M84](/packages/irazasyed-telegram-bot-sdk)[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

343121.4M79](/packages/google-cloud-core)[stechstudio/laravel-zipstream

A fast and simple streaming zip file downloader for Laravel.

4633.7M3](/packages/stechstudio-laravel-zipstream)[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)

PHPackages © 2026

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