ekreative / uuid-extra-bundle
Paramconverter, Normalizer and Form Type for Ramsey Uuid
Installs: 160 077
Dependents: 0
Suggesters: 0
Security: 0
Stars: 17
Watchers: 5
Forks: 12
Open Issues: 11
Type:symfony-bundle
Requires
- php: ^7.3 || ~8.0.0 || ~8.1.0
- ramsey/uuid: ^4.2.3
- sensio/framework-extra-bundle: ^5.6.1 || 6.2.6
- symfony/framework-bundle: ^5.4.2 || ^6.0.2
Requires (Dev)
- doctrine/coding-standard: ^9.0
- phpunit/phpunit: ^9.5.11
- psalm/plugin-phpunit: ^0.16.1
- symfony/browser-kit: ^5.4.2 || ^6.0.1
- symfony/form: ^5.4.2 || ^6.0.2
- symfony/monolog-bundle: ^3.7.1
- symfony/serializer: ^5.4.2 || ^6.0.2
- symfony/validator: ^5.4.2 || ^6.0.2
- symfony/yaml: ^5.4.2 || ^6.0.2
- vimeo/psalm: ^4.18.1
Conflicts
- ramsey/collection: <1.2.0
- symfony/browser-kit: <5.3.7
- symfony/cache: <5.3.7
- symfony/config: <5.3.7
- symfony/console: <5.3.7
- symfony/dependency-injection: <5.3.7
- symfony/dom-crawler: <5.3.7
- symfony/error-handler: <5.3.7
- symfony/event-dispatcher: <5.3.7
- symfony/filesystem: <5.3.7
- symfony/finder: <5.3.7
- symfony/http-foundation: <5.3.7
- symfony/http-kernel: <5.3.7
- symfony/monolog-bridge: <5.3.7
- symfony/options-resolver: <5.3.7
- symfony/property-access: <5.3.7
- symfony/property-info: <5.3.7
- symfony/routing: <5.3.7
- symfony/var-dumper: <5.3.7
- symfony/var-exporter: <5.3.7
- dev-master
- 4.2.0
- 4.1.0
- 4.0.0
- 3.2.1
- 3.2.0
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.2
- 3.0.1
- 3.0.0
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.1
- 2.0.0
- 1.0.0
- dev-dependabot/composer/symfony/form-5.4.21
- dev-dependabot/composer/symfony/serializer-5.4.21
- dev-dependabot/composer/symfony/string-5.4.21
- dev-dependabot/composer/symfony/framework-bundle-5.4.21
- dev-dependabot/github_actions/ridedott/merge-me-action-2.10.43
- dev-dependabot/composer/slevomat/coding-standard-7.2.1
- dev-rename
- dev-uuid3
This package is auto-updated.
Last update: 2024-11-06 18:53:57 UTC
README
A convenient bundle for using ramsey/uuid in your project
Install
Composer
php composer.phar require ekreative/uuid-extra-bundle
AppKernel
Include the bundle in your AppKernel
public function registerBundles() { $bundles = array( ... new Ekreative\UuidExtraBundle\EkreativeUuidExtraBundle()
Config
No config needed
Param Converter
Use just like any other param converter
/** * @ParamConverter("uuid", class="Ramsey\Uuid\UuidInterface") * @Route("/simple/{uuid}") */ public function simpleAction(UuidInterface $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(UuidInterface $uuid) { return new Response($uuid->toString()); }
Also works for optional params
/** * @Route("/optional/{uuid}") */ public function simpleAction(UuidInterface $uuid = null) { return new Response($uuid ? $uuid->toString() : 'no uuid'); }
Serializer
Also like a normalizer should
$this->serializer->serialize($uuid, 'json')
Results in "f13a5b20-9741-4b15-8120-138009d8e0c7"
And the other way around
$this->serializer->denormalize('"f13a5b20-9741-4b15-8120-138009d8e0c7"', UuidInterface::class, 'json')
Results in $uuid
Works in your Objects etc.
Form Type
Does everything you'd expect
->add('uuid', UuidType:class)
And if your model has
/** * @Assert\Uuid */ private $uuid;
It will automatically use the UuidType