2017 © Pedro Peláez
 

library drift

A lightweight PHP library for mapping data to PHP classes

image

kevbradwick/drift

A lightweight PHP library for mapping data to PHP classes

  • Sunday, November 6, 2016
  • by kevbradwick
  • Repository
  • 0 Watchers
  • 1 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Drift

Build Status, (*1)


Drift is a PHP library for mapping arbitrary data to PHP classes., (*2)

Installation

Drift is available on Packagist, so you can use composer;, (*3)

composer require kevbradwick/drift

Usage

Say you have a class with private member variables like this;, (*4)

namespace Application;

class Actor
{
    /**
     * @Drift\String()
     */
    private $name;

    /**
     * @Drift\Int()
     */
    private $age;

    /**
     * @Drift\Date(field="date_of_birth")
     */
    private $dateOfBirth;
}

And you have some data, possibly consumed from an API, that looks like this;, (*5)

$data = [
    'name' => 'Arnold Schwarzenegger',
    'age' => 68,
    'date_of_birth' => 'July 30, 1947'
]

You can then use Drift\Mapper to create a new instance of the class, initialised with the data., (*6)

use Drift\Mapper;
use Drift\Reader\AnnotationReader;
use Application\Actor;

$mapper = new Mapper(new AnnotationReader());
$mapper->setData($data);

$actor = $mapper->instantiate(Actor::class);

In addition to annotations, you can specify mapping using Yaml or plain old php., (*7)

Full documentation can be found on the Wiki., (*8)

The Versions

06/11 2016

dev-master

9999999-dev https://github.com/kevbradwick/drift

A lightweight PHP library for mapping data to PHP classes

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Kevin Bradwick

mapper data data mapper

06/11 2016

1.2.0

1.2.0.0 https://github.com/kevbradwick/drift

A lightweight PHP library for mapping data to PHP classes

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Kevin Bradwick

mapper data data mapper

20/02 2016

1.1.0

1.1.0.0 https://github.com/kevbradwick/drift

A lightweight PHP library for mapping data to PHP classes

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Kevin Bradwick

mapper data data mapper

20/02 2016

1.0.1

1.0.1.0 https://github.com/kevbradwick/drift

A lightweight PHP library for mapping data to PHP classes

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Kevin Bradwick

mapper data data mapper

20/02 2016

1.0.0

1.0.0.0 https://github.com/kevbradwick/drift

A lightweight PHP library for mapping data to PHP classes

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Kevin Bradwick

mapper data data mapper