andytruong / serializer
Very simple library to serialize/unserialize PHP objects.
v0.1.4
2014-09-10 06:44 UTC
Requires
- php: >=5.4
- andytruong/event: ~0.1.0
- andytruong/phpfns: ~0.1.0
Requires (Dev)
- doctrine/orm: ~2.4.0
Suggests
- doctrine/orm: ~2.4.0
This package is not auto-updated.
Last update: 2024-11-19 03:33:08 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.