PHPackages                             fabstei/shorturl-bundle - 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. fabstei/shorturl-bundle

AbandonedArchivedSymfony-bundle[Utility &amp; Helpers](/categories/utility)

fabstei/shorturl-bundle
=======================

Provides a Shorturl Service for your Symfony2 Project.

0.2.0(12y ago)122.5k3[2 issues](https://github.com/fabstei/shorturl-bundle/issues)MITPHPPHP &gt;=5.3.2

Since Dec 15Pushed 9y ago3 watchersCompare

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

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

Provides short urls for your Symfony2 Project.
==============================================

[](#provides-short-urls-for-your-symfony2-project)

[![SensioLabsInsight](https://camo.githubusercontent.com/9c8f4cfd9efdd76d5066f49f8be20642981e0b4773b40a4fee00b423eb31e44d/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f61366566663163302d343062642d343261362d393834662d6263333864363432643966352f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/a6eff1c0-40bd-42a6-984f-bc38d642d9f5)

[![Build Status](https://camo.githubusercontent.com/06d88e290f7575ddd26b96bb31138bdbf3a910a9f947b7578c135829c3638042/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f666162737465692f73686f727475726c2d62756e646c652e706e67)](http://travis-ci.org/fabstei/shorturl-bundle)

> Note: This bundle is under development. Things will change and might break. [Feedback](https://github.com/fabstei/shorturl-bundle/issues) is very welcome!

About
-----

[](#about)

This Bundle allows you to

- Generate short urls
- Manage redirections from short to long urls

The bundle is based on the shorturl class by [Jonathan Snook](http://snook.ca/archives/php/url-shortener).

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

[](#installation)

Using Composer, add to `composer.json`:

```
{
    "require": {
        "fabstei/shorturl-bundle": "0.2.0"
    }
}

```

Then install/update your vendors:

```
php composer.phar update

```

Add the bundle to your AppKernel.php:

```
new Fabstei\ShorturlBundle\FabsteiShorturlBundle(),

```

Update your doctrine database schema (`doctrine:schema:update --force`)

Import the routes from your routing.yml:

```
# Redirection from short to long urls
redirect:
    resource: "@FabsteiShorturlBundle/Resources/config/routing/redirect.yml"
    #hostname_pattern: example.com
    #prefix: /shorturls

# Shorturl management
shorturl:
    resource: "@FabsteiShorturlBundle/Resources/config/routing/url.yml"

```

The optional [hostname pattern](http://symfony.com/doc/master/components/routing/hostname_pattern.html) (new in Symfony 2.2) allows you to use a seperate domain for your short urls.

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

[](#configuration)

The bundle provides sensible default values but one might want to customize the codeset used to generate unique tokens (used as short urls).

```
fabstei_shorturl:
    codeset: abcABC123-_! # Default: abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ23456789

```

Usage
-----

[](#usage)

The bundle comes with two services:

- [fabstei\_shorturl.tokenizer](https://github.com/fabstei/shorturl-bundle/blob/master/Service/TokenizerInterface.php) to generate tokens to use as short urls (such as example.com/a3x)
- [fabstei\_shorturl.manager](https://github.com/fabstei/shorturl-bundle/blob/master/Model/UrlManagerInterface.php) to manage redirections (store long urls and their associated token)

It also provides a controller to handle redirections as well as a controller, views and forms to manage the redirections (by default accessible from /url-manager). Custom shorturls can be used to replace the default tokens (calculated from the redirection id). Furthermore, you may use `_locale` anywhere in the long urls you store, which is replaced by the current requests locale on redirection.

Both services are also accessible via cli commands:

```
php app/console fabstei:shorturl:add    # Add a long url, returns the short token
php app/console fabstei:shorturl:get    # Retrieve a long url associated with a token
php app/console fabstei:shorturl:update # Update the long url associated with a token
php app/console fabstei:shorturl:remove # Remove a redirection
php app/console fabstei:shorturl:list   # Get a list of all stored redirections

php app/console fabstei:token:codeset   # Get the codeset used to generate tokens
php app/console fabstei:token:encode    # Calculate a token from an integer
php app/console fabstei:token:decode    # Calculate the integer from a given token

```

TODO
----

[](#todo)

- Add proper tests
- Improve general code quality

Dependencies
------------

[](#dependencies)

- [doctrine/orm](https://packagist.org/packages/doctrine/orm)
- [symfony/framework-bundle](https://packagist.org/packages/symfony/framework-bundle)

Credits
-------

[](#credits)

- [Jonathan Snook](http://snook.ca/archives/php/url-shortener) for the base class.
- [Tim Nagel](https://github.com/merk) for help on IRC and code samples.
- [FriendsOfSymfony](https://github.com/FriendsOfSymfony/) for the best code to learn from; [FOSUserBundle](https://github.com/FriendsOfSymfony/FOSUserBundle) for the object manager.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

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.

###  Release Activity

Cadence

Every ~400 days

Total

2

Last Release

4500d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c300080af869451cb448253fa81868d1821415c305e518b98f43bc564ec73a63?d=identicon)[fabstei](/maintainers/fabstei)

---

Top Contributors

[![fabstei](https://avatars.githubusercontent.com/u/1098434?v=4)](https://github.com/fabstei "fabstei (32 commits)")

---

Tags

Shorturl

### Embed Badge

![Health badge](/badges/fabstei-shorturl-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/fabstei-shorturl-bundle/health.svg)](https://phpackages.com/packages/fabstei-shorturl-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[leapt/core-bundle

Symfony LeaptCoreBundle

2529.1k4](/packages/leapt-core-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1714.8k8](/packages/2lenet-crudit-bundle)[anime-db/anime-db

The application for making home collection anime

252.1k2](/packages/anime-db-anime-db)

PHPackages © 2026

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