atphp/serializer

Very simple library to serialize/unserialize PHP objects.

v0.1.4 2014-09-10 06:44 UTC

This package is auto-updated.

Last update: 2024-11-12 20:39:39 UTC


README

Very simple Serializer/Unserializer for PHP objects.

If we have this very simple class:

<?php
class Person {
    private $name;
    public function getName() { return $this->name; }
    public function setName($name) { $this->name = $name; }
}

Then we can easy create new Person object from a structured array:

<?php
$person = new Person();
$person->setName('Johnson American');
(new AndyTruong\Serializer\Serializer())
    ->toArray($person); // ['name' => 'Johnson American']

We can also easy create new Person object from a structured array:

<?php
$person = (new AndyTruong\Serializer\Unserializer())
    ->fromArray(['name' => 'Johnson America']);

The library also supports Trait, nested objects, … check ./resources/docs for more informations.