PHPackages                             vinelab/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. vinelab/url-shortener

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

vinelab/url-shortener
=====================

URL shortening the easy way.

v1.2.0(10y ago)6217.2k↓37.5%19[5 PRs](https://github.com/Vinelab/url-shortener/pulls)MITPHPPHP &gt;=5.4.0

Since May 11Pushed 6y ago9 watchersCompare

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

READMEChangelog (4)Dependencies (7)Versions (4)Used By (0)

URL Shortener PHP Package
=========================

[](#url-shortener-php-package)

[![Latest Stable Version](https://camo.githubusercontent.com/1ceea93e3bdf361337f6dabd6d661addbb0744c2e9e87ed2d9e06bbee07e51ed/68747470733a2f2f706f7365722e707567782e6f72672f76696e656c61622f75726c2d73686f7274656e65722f762f737461626c65)](https://packagist.org/packages/vinelab/url-shortener)[![Latest Unstable Version](https://camo.githubusercontent.com/53ae70dcee5a2dff6da5f8b330bcb6f5f9389ceb508e96677aae83c1b8d39cb9/68747470733a2f2f706f7365722e707567782e6f72672f76696e656c61622f75726c2d73686f7274656e65722f762f756e737461626c65)](https://packagist.org/packages/vinelab/url-shortener)[![Total Downloads](https://camo.githubusercontent.com/f23fdc8b549b0233220ea90768dec3f72856691509020d29bf51d019cb020cde/68747470733a2f2f706f7365722e707567782e6f72672f76696e656c61622f75726c2d73686f7274656e65722f646f776e6c6f616473)](https://packagist.org/packages/vinelab/url-shortener)[![Build Status](https://camo.githubusercontent.com/9c98fdef53c3ec3d586d8cf68622dc71dc92376492a0050a4081ce758f9c0c05/68747470733a2f2f7472617669732d63692e6f72672f56696e656c61622f75726c2d73686f7274656e65722e737667)](https://travis-ci.org/Vinelab/url-shortener)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/bc5e21d6464da925307eb5be6b5010262cc7e63044b70a4af9135e3ef83c5d69/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f56696e656c61622f75726c2d73686f7274656e65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Vinelab/url-shortener/?branch=master)[![License](https://camo.githubusercontent.com/d53204f4d2614a9e759e244653f2b8b7891c99735733450384da992d12479f7d/68747470733a2f2f706f7365722e707567782e6f72672f76696e656c61622f75726c2d73686f7274656e65722f6c6963656e7365)](https://packagist.org/packages/vinelab/url-shortener)

**`vinelab/url-shortener`** is a PHP framework agnostic Package that makes it easy to shorten your URL's, with your favourite URL Shortening provider such as (Bit.ly, Goo.gl, Ow.ly).

*The URL Shortening Providers are online services that takes long URLs and squeezes them into fewer characters to make the link easier to share, tweet, or send by email.*

The package requires PHP 5.4+ and comes bundled with a Laravel 5 Facade and a Service Provider to simplify the optional framework integration and follows the FIG standard PSR-4 to ensure a high level of interoperability between shared PHP code and is fully unit-tested.

Highlights
----------

[](#highlights)

- Supportes [Bit.ly](https://bitly.com/)

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

[](#installation)

The recommended way to install this package is via `Composer`.

#### Via Composer

[](#via-composer)

A. Run this composer command:

```
	composer require vinelab/url-shortener:*
```

B. **Or** manually add the package to your `composer.json` and run `composer update`.

```
    {
        "require": {
            "vinelab/url-shortener": "*"
        }
    }
```

Integrations
------------

[](#integrations)

`url-shortener` is framework agnostic and as such can be integrated easily natively or with your favorite framework.

### Laravel:

[](#laravel)

The `url-shortener` package has optional support for Laravel 5 and it comes bundled with a Service Provider for easier integration.

After you have installed the package correctly, just follow the instructions.

.1. Register the service provider in your `config/app.php`:

```
    'providers' => array(
        ...
		'Vinelab\UrlShortener\UrlShortenerServiceProvider'
    ),
```

The service provider will automatically alias the `Vinelab\UrlShortener\Shorten` class, so you can easily use the `Shorten` facade anywhere in your app.

.2. Publish the configuration file:

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

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

[](#configuration)

.1. Open `url-shortener.php` and select your default provider:

```
	'default' => 'bitly',
```

.2. Then add your provider token:

```
        'bitly' => [
            'domain' => 'https://api-ssl.bitly.com',
            'endpoint' => '/v3/shorten',
            'token' => 'YOUR-TOKEN-HERE',
        ],
```

Note: It's very recommended to not add your token (any sensetive data) to the config file instead reference it to a `.env` variable.

And to do so:

1. replace the `'token' => 'YOUR-TOKEN-HERE',` with `'token' => env('BITLY_TOKEN'),`
2. open your `.env` file and add the token variable there with the token value: `BITLY_TOKEN=YOUR-TOKEN-HERE`.
3. add the variable `BITLY_TOKEN=` to the `.env.example` for other developers.

Usage
-----

[](#usage)

##### With Laravel:

[](#with-laravel)

The easiest way is to use it is by the `Shorten` facade.

```
$long_url = 'http://testing.tst/something/12345/something-else/54321';

$short_url = Shorten\Shorten::url($long_url); // returns the short version of the long_url as a string
```

Test
----

[](#test)

To run the tests, run the following command from the project folder.

```
$ ./vendor/bin/phpunit
```

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

[](#contributing)

### Support new provider

[](#support-new-provider)

To add support for a new URL shortening provider:

1. write a driver for your URL Shortener service. check the `Bitly` driver `Vinelab\UrlShortener\Drivers\Bitly` class.
2. add you driver configuration to the config file.
3. write tests for your drvier.
4. update the `README` file
5. check out the [Contribution Guide](https://github.com/Vinelab/url-shortener/blob/master/CONTRIBUTING.md) for general details.

Support
-------

[](#support)

[On Github](https://github.com/Vinelab/url-shortener/issues)

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Abed Halawi](https://github.com/Mulkave)
- [Mahmoud Zalt](https://github.com/Mahmoudz)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/Vinelab/url-shortener/blob/master/LICENSE) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

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

Total

4

Last Release

3800d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/28e3096ef1cc86da63cc85628e13607ea3ec844a70d7bb1b49f34d99e0b92187?d=identicon)[Mahmoudz](/maintainers/Mahmoudz)

---

Top Contributors

[![Mahmoudz](https://avatars.githubusercontent.com/u/1983984?v=4)](https://github.com/Mahmoudz "Mahmoudz (45 commits)")[![Mulkave](https://avatars.githubusercontent.com/u/2647333?v=4)](https://github.com/Mulkave "Mulkave (3 commits)")

---

Tags

urllaravelbitlyurl shortenershorten

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[prologue/alerts

Prologue Alerts is a package that handles global site messages.

3486.1M30](/packages/prologue-alerts)[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[shivella/laravel-bitly

Laravel package for generating bitly url

75789.0k1](/packages/shivella-laravel-bitly)

PHPackages © 2026

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