korbeil/automapper-bootstrap

There is no license information available for the latest version (dev-main) of this package.

dev-main 2021-02-02 22:53 UTC

This package is auto-updated.

Last update: 2021-12-31 00:22:53 UTC


README

Simple bootstrap to use Jane's AutoMapper.

It will configure the AutoMapper to work on a "normal" environnement (where normal is defined by my usual standards) and in a standalone mode. If you want to use the AutoMapper with Symfony, please use the corresponding bundle.

How to use:

use Korbeil\AutoMapperBootstrap\AutoMapper;

$autoMapper = AutoMapper::bootstrap(__DIR__ . '/cache');

class User
{
    public string $name;
    public int $age;
}

$data = [
    'name' => 'Baptiste',
    'age' => 29
];

$user = $autoMapper->map($data, User::class);
//object(User)#1286 (2) {
//  ["name"]=>
//  string(8) "Baptiste"
//  ["age"]=>
//  int(29)
//}