2017 © Pedro Peláez
 

symfony-bundle short-url-bundle

Provides a service and twig extension for getting short urls like http://your.host/~short

image

alanmastro/short-url-bundle

Provides a service and twig extension for getting short urls like http://your.host/~short

  • Friday, May 4, 2018
  • by marco.bicchi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 5 Versions
  • 86 % Grown

The README.md

ShortUrlBundle

This bundle provides a service and twig extension for getting short urls like http://your.host/~short, (*1)

Build Status, (*2)

Installation

Add this bundle to your project

Using the vendors script, (*3)

Add the following lines in your deps file:, (*4)

[BumzShortUrlBundle]
    git=git://github.com/biozshock/ShortUrlBundle.git
    target=bundles/Bumz/ShortUrlBundle

Run the vendors script:, (*5)

$ php bin/vendors install

Using Git submodule, (*6)

$ git submodule add git://github.com/biozshock/ShortUrlBundle.git vendor/bundles/Bumz/ShortUrlBundle

Add the Bumz namespace to your autoloader

<?php
// app/autoload.php

$loader->registerNamespaces(array(
    'Bumz' => __DIR__.'/../vendor/bundles',
    // your other namespaces
));

Add this bundle to your application's kernel

<?php
// app/AppKernel.php

public function registerBundles()
{
    return array(
        // ...
        new Bumz\ShortUrlBundle\BumzShortUrlBundle(),
        // ...
    );
}

Add bundle's routing

# /app/config/routing.yml
BumzShortUrlBundle:
    resource: "@BumzShortUrlBundle/Resources/config/routing.yml"
    prefix:   /

Examples

Short url in a controller

<?php

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class UsersController extends Controller
{
    public function getUserProfileShortAction()
    {

        ...

        $longUrl = $this->get('bumz_short_url.shortener')->shorten('http://example.com');
        // $longUrl = '/~ShE'

        ...
    }
}

Get long url in controller

<?php

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class UsersController extends Controller
{
    public function getUserProfileShortAction()
    {

        ...

        $shortUrl = 'aUty';
        $longUrl = $this->get('bumz_short_url.shortener')->getLong($shortUrl);
        // $longUrl = 'http://example.com'

        ...
    }
}

Get short url in a twig template

{{ 'http://example.com' | shortenUrl }}
{# this will output something like /~ShE #}

The Versions

04/05 2018

dev-master

9999999-dev https://github.com/alanmastro/ShortUrlBundle

Provides a service and twig extension for getting short urls like http://your.host/~short

  Sources   Download

MIT

The Requires

 

by Marco Bicchi

url shortener short url

04/05 2018

1.0.0.3

1.0.0.3 https://github.com/alanmastro/ShortUrlBundle

Provides a service and twig extension for getting short urls like http://your.host/~short

  Sources   Download

MIT

The Requires

 

by Marco Bicchi

url shortener short url

04/05 2018

1.0.0.2

1.0.0.2 https://github.com/alanmastro/ShortUrlBundle

Provides a service and twig extension for getting short urls like http://your.host/~short

  Sources   Download

MIT

The Requires

 

by Marco Bicchi

url shortener short url

04/05 2018

1.0.0.1

1.0.0.1 https://github.com/alanmastro/ShortUrlBundle

Provides a service and twig extension for getting short urls like http://your.host/~short

  Sources   Download

MIT

The Requires

 

by Marco Bicchi

url shortener short url

04/05 2018

v1.0.0.0

1.0.0.0 https://github.com/alanmastro/ShortUrlBundle

Provides a service and twig extension for getting short urls like http://your.host/~short

  Sources   Download

MIT

The Requires

 

by Marco Bicchi

url shortener short url