mcfedr/uuid-paramconverter

This package is abandoned and no longer maintained. The author suggests using the mcfedr/uuid-extra-bundle package instead.

A sensi paramconverter for receiving uuids as url params

Installs: 53 892

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 2

Forks: 3

Open Issues: 0

Type:symfony-bundle

2.3.1 2018-02-23 13:14 UTC

This package is auto-updated.

Last update: 2019-02-05 10:52:20 UTC


README

A convenient bundle for using ramsey/uuid in your controllers

Latest Stable Version License Build Status SensioLabsInsight

Install

Composer

php composer.phar require mcfedr/uuid-paramconverter

AppKernel

Include the bundle in your AppKernel

public function registerBundles()
{
    $bundles = array(
        ...
        new Mcfedr\UuidParamConverterBundle\McfedrUuidParamConverterBundle()

Config

No config needed

Usage

Use just like any other param converter

/**
 * @ParamConverter("uuid", class="Ramsey\Uuid\Uuid")
 * @Route("/simple/{uuid}")
 */
public function simpleAction(Uuid $uuid)
{
    return new Response($uuid->toString());
}

Most of the time its going to work automatically, as long as you use type hinting on your action

/**
 * @Route("/automatic/{uuid}")
 */
public function simpleAction(Uuid $uuid)
{
    return new Response($uuid->toString());
}

Also works for optional params

/**
 * @Route("/optional/{uuid}")
 */
public function simpleAction(Uuid $uuid = null)
{
    return new Response($uuid ? $uuid->toString() : 'no uuid');
}