2017 © Pedro Peláez
 

library jaitec-alias

A simple alias generator

image

jlaso/jaitec-alias

A simple alias generator

  • Tuesday, October 17, 2017
  • by jlaso
  • Repository
  • 1 Watchers
  • 1 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

JaitecAliasBundle

This bundle provides helpers to generate pseudo-random alias., (*1)

SensioLabsInsight, (*2)

Installation

Add AliasBundle to your vendor/bundles/ dir

::, (*3)

$ git submodule add git://github.com/jlaso/JaitecAliasBundle.git vendor/bundles/Jaitec/AliasBundle

or add this to deps, (*4)

[JaitecAliasBundle]    
    git=http://github.com/jlaso/JaitecAliasBundle
    target=/bundles/Jaitec/AliasBundle

and run, (*5)

$ php bin/vendors install

Add the Jaitec namespace to your autoloader

::, (*6)

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

Add AliasBundle to your application kernel

::, (*7)

// app/AppKernel.php

public function registerBundles()
{
    return array(
        // ...
        new Jaitec\AliasBundle\JaitecAliasBundle(),
        // ...
    );
}

Usage

AliasBundle provides this service to generate pseudo-random alias :, (*8)

  • jaitec_alias.main implements AliasGeneratorInterface

Instead of those specialized services, you can also inject jaitec_alias.main, which provides shortcuts to all of the other services and allow you to only inject a single dependancy., (*9)

Sample

For example generating alias for an url based on row ID in mysql table, (*10)

First get the object throught dependency inject, (*11)

$this->alias = $this->container->get('jaitec_alias.main');

Now generate the alias, (*12)

$alias = $this->alias->encode($record->getId(),4);

The Versions

17/10 2017

dev-master

9999999-dev https://github.com/jlaso/JaitecAliasBundle

A simple alias generator

  Sources   Download

MIT

id jaitec