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

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

arirah-shortener/url-shortener
==============================

URL shortener service with popular URL shortener provider

12PHP

Since Jan 11Pushed 6y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

URL shortener
=============

[](#url-shortener)

URL shortener package have ability to support different URL shortener providers.

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

[](#installation)

Install composer dependencies with `docker run --rm -v $(pwd):/app composer install`

You can also run make command like `make init`

Run examples `docker run --rm -v $(pwd):/app -w /app php:cli php examples/bitly.php`

Docker phpunit tests command : `docker run --rm -v $(pwd):/app -w /app php:cli php ./vendor/bin/phpunit tests/urlTest`

Use the package manager composer () to install URL shortener.

```
composer require arirah-shortener/url-shortener:dev-master
```

Usage
-----

[](#usage)

##### Provider

[](#provider)

Currently we have two providers bitly and tinyurl more will be added soon.

##### TinyUrl

[](#tinyurl)

In your file use like this , you must have to set provider instance :

```
$shortener =  new UrlShortener(new \ArirahShortener\UrlShortener\TinyUrl());
```

##### Bitly

[](#bitly)

For bitly you need to set API access\_token

```
$shortener =  new UrlShortener(new \ArirahShortener\UrlShortener\Bitly('f7bb93c3ae74d10db0de48e9e038f13000e07d05'));
```

Currently we have two provider bitly and tiny url. Default provider is tinyurl. For bit.ly you have to set access token from bitly account [https://bitly.com/a/oauth\_apps](https://bitly.com/a/oauth_apps)No access\_token ? dont worry it automatically switch to tinyurl provider.

Example :

```
#BitLy
try {
    $access_token = new ArirahShortener\UrlShortener\AccessToken('f7bb93c3ae74d10db0de48e9e038f13000e07d05');
    $shortener =  new UrlShortener(new ArirahShortener\UrlShortener\Bitly($access_token));
    echo (string) $shortener->shorten('https://news.google.com/?hl=en-US&gl=US&ceid=US:en');
} catch (Exception $e) {
    echo $e->getMessage() ;
}

# TinyURL
try {
    $shortener =  new UrlShortener();
    echo (string) $shortener->shorten('https://news.google.com/?hl=en-US&gl=US&ceid=US:en');
} catch (Exception $e) {
    echo $e->getMessage() ;
}
```

Return :

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

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

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/728d2e5689f194208ff4f2a4058147af5a19084fda18ef5e401aca1ae539e252?d=identicon)[arirah](/maintainers/arirah)

---

Top Contributors

[![arirah](https://avatars.githubusercontent.com/u/3797429?v=4)](https://github.com/arirah "arirah (8 commits)")

### Embed Badge

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

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

PHPackages © 2026

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