PHPackages                             hatchetaustralia/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hatchetaustralia/laravel-url-shortener

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

hatchetaustralia/laravel-url-shortener
======================================

Powerful URL shortening tools in Laravel

v0.6.0(3y ago)08791MITPHPPHP ^8.0

Since Apr 16Pushed 1mo agoCompare

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

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

laravel-url-shortener
=====================

[](#laravel-url-shortener)

Powerful URL shortening tools in Laravel

 [![](https://camo.githubusercontent.com/2ecfd2c8f79f7b3fe49f991946b233911d8c5f02dc0162ec43942eb739187eb1/68747470733a2f2f7472617669732d63692e6f72672f486174636865742f6c61726176656c2d75726c2d73686f7274656e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Hatchet/laravel-url-shortener) [![](https://camo.githubusercontent.com/f352b7b9eb138c2ee8eedda0cd8d75c79afb287bcc44241fa2e35f46f9740d2f/68747470733a2f2f706f7365722e707567782e6f72672f686174636865746175737472616c69612f6c61726176656c2d75726c2d73686f7274656e65722f646f776e6c6f616473)](https://packagist.org/packages/hatchetaustralia/laravel-url-shortener) [![](https://camo.githubusercontent.com/bacd22df48ce29e34fc3d6867a1677689035ca710f4fe7ed54773308ec56964d/68747470733a2f2f706f7365722e707567782e6f72672f686174636865746175737472616c69612f6c61726176656c2d75726c2d73686f7274656e65722f76657273696f6e)](https://packagist.org/packages/hatchetaustralia/laravel-url-shortener) [![](https://camo.githubusercontent.com/169d233923f31b4cb414bdd061342774c171993ca744aa8edf8f3a7a43117c9b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f486174636865742f6c61726176656c2d75726c2d73686f7274656e65722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Hatchet/laravel-url-shortener/) [![](https://camo.githubusercontent.com/4c597dec06493bcd539408a520dc6f8c999c40540c2e4534b2bed26b6b968bba/68747470733a2f2f706f7365722e707567782e6f72672f686174636865746175737472616c69612f6c61726176656c2d75726c2d73686f7274656e65722f6c6963656e7365)](https://packagist.org/packages/hatchetaustralia/laravel-url-shortener)

- [Installation](#installation)
    - [Requirements](#requirements)
    - [Laravel 5.5+](#laravel-55)
    - [Laravel 5.1-5.4](#laravel-51-54)
- [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 hatchetaustralia/laravel-url-shortener
```

### Requirements

[](#requirements)

This package has the following requirements:

- PHP 7.1 or higher
- Laravel 5.1 or higher

### 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' => [
   ...
   Hatchet\UrlShortener\UrlShortenerServiceProvider::class,
   ...
],
```

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 Laravel's [core components](https://laravel.com/docs/5.0/extending#managers-and-factories), you can add your own drivers for this package. You can do this by adding the following code to a central place in your application (preferably a service provider).

```
public function boot(ShortenerManager $shorteners)
{
    $shorteners->extend('my_driver', function ($app, $config) {
       // Return your driver instance here
    });
}
```

Once you have registered your driver you can call it 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)

- [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

40

—

FairBetter than 88% of packages

Maintenance59

Moderate activity, may be stable

Popularity18

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

Recently: every ~269 days

Total

9

Last Release

1358d ago

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

v0.6.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a3485b619f8f287aba5325e29d894b0d43b16cc9d413816a39c0b4dc2aa8dd8?d=identicon)[hatchet](/maintainers/hatchet)

---

Top Contributors

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

---

Tags

urllaravellumenbitlyshortenershorteningtinyurlshorte.st

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laracrafts/laravel-url-shortener

Powerful URL shortening tools in Laravel

97110.7k](/packages/laracrafts-laravel-url-shortener)[google/cloud-core

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

343121.4M79](/packages/google-cloud-core)[shivella/laravel-bitly

Laravel package for generating bitly url

75789.0k1](/packages/shivella-laravel-bitly)[gallib/laravel-short-url

A Laravel package to shorten urls

16516.4k](/packages/gallib-laravel-short-url)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[vinelab/url-shortener

URL shortening the easy way.

6217.2k](/packages/vinelab-url-shortener)

PHPackages © 2026

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