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

ActiveLibrary

soleo/url-shortener
===================

Make the URLs shorter

00[1 issues](https://github.com/soleo/url-shortener/issues)PHP

Since Mar 21Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

UrlShortener
============

[](#urlshortener)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fb238c8df1703d1e89dcc5cffba5e6eeedf9f1c03ca918460d299adad6ccf3c0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f6c656f2f75726c2d73686f7274656e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/soleo/url-shortener)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/e3f7d6d71f72dc9b765742a327bd4dc8719a3d0fc68b68fa57189c6fae90ba83/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f736f6c656f2f75726c2d73686f7274656e65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/soleo/url-shortener)[![Coverage Status](https://camo.githubusercontent.com/07c014a483cbd29e3cb7c344ddf472f28a38facc49daee29f9fba332ab6846cf/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f736f6c656f2f75726c2d73686f7274656e65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/soleo/url-shortener/code-structure)[![StyleCI](https://camo.githubusercontent.com/598a970109b9797008c611d2714d261f8f04fb402f9ae0a7d9f624f7d7484f48/68747470733a2f2f7374796c6563692e696f2f7265706f732f35333532323138372f736869656c64)](https://styleci.io/repos/53522187)[![Quality Score](https://camo.githubusercontent.com/5d383a2cd42d5e3f736174398eb6e541cdf7b4db66cb14a1c965bb0f6a967a8d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f736f6c656f2f75726c2d73686f7274656e65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/soleo/url-shortener)[![Total Downloads](https://camo.githubusercontent.com/fc7aa36125965c1c86149996b9425765f89156bd3da0002ac0a5143c48f082e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f6c656f2f75726c2d73686f7274656e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/soleo/url-shortener)

A Simple, Self-Hosted URL Shortener with MongoDB.

Install
-------

[](#install)

Via Composer

```
$ composer require soleo/url-shortener
```

Usage
-----

[](#usage)

```
use Soleo\UrlShortener\MongoConnection;
use Soleo\UrlShortener\Shorty;

require "vendor/autoload.php";

$mongoURI = "mongodb://demo:demodemo@ds045757.mlab.com:45757/url_shortener";
$mongoConn = new MongoConnection($mongoURI);
$shorty = new Shorty($mongoConn);
if (isset($_GET['longurl'])) {
    echo $shorty->getShortUrl($_GET['longurl']);
    exit;
}
// Get Long URL
$slug = preg_replace('[^A-Za-z0-9]', '', $_SERVER['REQUEST_URI']);
$longURL = $shorty->getLongUrl($slug, true);
header("Location: ".$longURL, true, 302);
exit;
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

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

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Xinjiang Shao](https://github.com/soleo)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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/45b77a64757ff23b3b499f06c91350e1564e964ec4fd733b7e2bc616fc72897a?d=identicon)[soleo](/maintainers/soleo)

---

Top Contributors

[![soleo](https://avatars.githubusercontent.com/u/635858?v=4)](https://github.com/soleo "soleo (21 commits)")

### Embed Badge

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

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

PHPackages © 2026

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