2017 © Pedro Peláez
 

symfony-bundle shorturl-bundle

Provides a Shorturl Service for your Symfony2 Project.

image

fabstei/shorturl-bundle

Provides a Shorturl Service for your Symfony2 Project.

  • Tuesday, June 21, 2016
  • by fabstei
  • Repository
  • 3 Watchers
  • 12 Stars
  • 2,196 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 3 Versions
  • 4 % Grown

The README.md

Provides short urls for your Symfony2 Project.

SensioLabsInsight, (*1)

Build Status, (*2)

Note: This bundle is under development. Things will change and might break. Feedback is very welcome!, (*3)

About

This Bundle allows you to, (*4)

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

The bundle is based on the shorturl class by Jonathan Snook., (*5)

Installation

Using Composer, add to composer.json:, (*6)

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

Then install/update your vendors:, (*7)

php composer.phar update

Add the bundle to your AppKernel.php:, (*8)

new Fabstei\ShorturlBundle\FabsteiShorturlBundle(),

Update your doctrine database schema (doctrine:schema:update --force), (*9)

Import the routes from your routing.yml:, (*10)

# 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 (new in Symfony 2.2) allows you to use a seperate domain for your short urls., (*11)

Configuration

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

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

Usage

The bundle comes with two services: * fabstei_shorturl.tokenizer to generate tokens to use as short urls (such as example.com/a3x) * fabstei_shorturl.manager to manage redirections (store long urls and their associated token), (*13)

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., (*14)

Both services are also accessible via cli commands:, (*15)

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

  • Add proper tests
  • Improve general code quality

Dependencies

Credits

The Versions

21/06 2016

dev-master

9999999-dev

Provides a Shorturl Service for your Symfony2 Project.

  Sources   Download

MIT

The Requires

 

by Fabian Steiner

shorturl

20/01 2014

0.2.0

0.2.0.0

Provides a Shorturl Service for your Symfony2 Project.

  Sources   Download

MIT

The Requires

 

by Fabian Steiner

shorturl

15/12 2012

0.1.0

0.1.0.0

Provides a Shorturl Service for your Symfony2 Project.

  Sources   Download

MIT

The Requires

 

by Fabian Steiner

shorturl