atphp / serializer
Very simple library to serialize/unserialize PHP objects.
Installs: 156
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 1
pkg:composer/atphp/serializer
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
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.