Download the PHP package gpaton/labelconverter-bundle without Composer

On this page you can find all versions of the php package gpaton/labelconverter-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package labelconverter-bundle

LabelConverter Bundle

 Introduction

This Symfony Bundle provides tools to convert an integer to a label like roman numeral, capital or lowercase letter

Label types currently supported are :

Tools included are :

Installation

 Install GpatonLabelConverterBundle

Simply run assuming you have installed composer.phar or composer binary:

$ php composer.phar require gpaton/labelconverter-bundle 1.0.*

 Enable the bundle

Finally, enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Gpaton\LabelConverterBundle\GpatonLabelConverterBundle(),

    );
}

 Usage

3 tools are provided to make your life easier, but you may not need to use all of them.

 Form field type

This tool is useful when you want to let the user choose in a form among label conversion types to use. Let's say for instance that you want the user to choose what type of label to use before answers in a quiz.

Add the form field in your Question form :

<?php
// Acme\DemoBundle\Form\QuestionType

// ...

class QuestionType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add(
            conversion',
            'gpaton_labelconverter',
            array(
                'label' => 'What kind of label to you want to use ?',
            )
        );
    }
}

You just have to get converter type choosen in your controller :

<?php
// Acme\DemoBundle\Controller\QuestionController

namespace Acme\DemoBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Acme\DemoBundle\Form\QuestionType;

class QuestionController extends Controller {

    public function indexAction(Request $request) {

        $form = $this->createForm(new QuestionType());
        $form->handleRequest($request);

        if ($form->isValid()) {

            $converterType = $form->get('conversion')->getData();

        }

        // ...
    }
}

Service

To use the converter in your controller, load the service gpaton.labelconverter.factory then call the getLabel method like this :

<?php
// Acme\DemoBundle\Controller\QuestionController

namespace Acme\DemoBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class QuestionController extends Controller {

    public function indexAction() {

        $labelConverterFactory = $this->get('gpaton.labelconverter.factory');

        $label = $labelConverterFactory->getLabel('RomanNumeral', 3);

        // ...
    }
}

the getlabel method takes 2 arguments :

  1. Converter type among the 4 currently supported :

    • RomanNumeral : I, II, III, ...
    • CapitalLetter : A, B, C, ...
    • LowercaseLetter : a, b, c, ...
    • ArabicNumeral : 1, 2, 3, ... (if you want to keep integers)
  2. The integer to convert

 Twig filter

Use filter with converter type in argument :

// Acme\DemoBundle\Resources\views\Demo\index.html.twig

Question 1 : Do you lifke pancakes ?<br />
{{ 1 | tolabel('CapitalLetter') }}/ Yes<br />
{{ 2 | tolabel('CapitalLetter') }}/ No

This template will render :

Question 1 : Do you like pancakes ?
A/ Yes
B/ No

Choose converter type among the 4 currently supported :

 Additonnal notes

 Letter conversion after 26

When you try to convert an integer greater than 26 to a capital or lowercase letter, the bundle use the system used by Excel with its columns names :

Integers supported

Only integers strictly greater than 0 are supported. Other numbers will throw a LabelConverterException you may catch.

 Invalid converter type

If you try to convert an integer by using a non existent converter type, a LabelConverterException will be thrown.

License

This bundle is under GPL v2 license. See the complete license in the bundle:

Resources/meta/LICENSE

All versions of labelconverter-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
symfony/framework-bundle Version ~2.1
symfony/form Version ~2.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gpaton/labelconverter-bundle contains the following files

Loading the files please wait ...