Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pew-pew-team/hydrator-jms
JMS Serializer Hydrator Bridge
https://github.com/pew-pew-team/hydrator-jms
adapter bridge deserialization hydrator jms jms-serializer mapper serialization
Last synced: 21 days ago
JSON representation
JMS Serializer Hydrator Bridge
- Host: GitHub
- URL: https://github.com/pew-pew-team/hydrator-jms
- Owner: pew-pew-team
- License: mit
- Created: 2024-03-17T11:42:30.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-03-26T22:06:32.000Z (9 months ago)
- Last Synced: 2024-11-08T19:47:11.319Z (about 1 month ago)
- Topics: adapter, bridge, deserialization, hydrator, jms, jms-serializer, mapper, serialization
- Language: PHP
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JMS Hydrator Bridge
A set of interfaces for mapping arbitrary values to their typed equivalents
and their inverses using the [JMS (jms/serializer)](https://jmsyst.com/libs/serializer)
package.## Installation
PewPew JMS Hydrator is available as Composer repository and can be installed
using the following command in a root of your project:```bash
$ composer require pew-pew/hydrator-jms
```More detailed installation [instructions are here](https://getcomposer.org/doc/01-basic-usage.md).
## Usage
Simple hydrator creation:
```php
$jms = PewPew\Hydrator\JMS\Builder::create();
```### Hydrator
```php
$hydrator = PewPew\Hydrator\JMS\Builder::create()
->createHydrator();$dto = $hydrator->hydrate(ExampleDTO::class, [
'id' => 42,
'name' => 'Vasya',
]);// object(ExampleDTO) {
// id: int(42),
// name: string("Vasya"),
// }
```### Extractor
```php
$extractor = PewPew\Hydrator\JMS\Builder::create()
->createExtractor();$data = $extractor->extract(new ExampleDTO(
id: 42,
name: 'Vasya',
));// array(2) [
// id => int(42),
// name => string("Vasya"),
// ]
```