lsv/hashidsbundle

Symfony bundle for integration of hashids lib to the container

Installs: 173

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

1.0.2 2016-05-12 01:13 UTC

This package is auto-updated.

Last update: 2021-12-27 15:46:57 UTC


README

Made for Symfony ^2.7 and also ^3.0

Installation

composer
composer require lsv/hashidsbundle

or add it your composer.json

"require": {
    "lsv/hashidsbundle": "^1.0"
}
Enable bundle
<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new \Lsv\HashidsBundle\LsvHashidsBundle(),
    );
}
Configuration

All configuration is optional, but this is the configuration availible

lsv_hashids:
    # Salt is default the same as your app secret
    salt: "%secret%"
    # Length is default 8
    length: 8
    # Alphabet is default "abcdefghij1234567890" - Default in hashids
    alphabet: "abcdefghij1234567890"

Usage

Controller

In your controller you can use

$this->get('lsv_hashids')->encode($id);
$this->get('lsv_hashids')->decode($string);
Twig

Also added 3 twig methods

id | hashids
id | encode_hashids
string | decode_hashids