Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Attributes Serialization

Code Coverage Latest Version Software License

Attributes Serialization is a library that serializes any object into a PHP primitive type

Features

  • Converts any type of object into a primitive type
  • Support for alias, alias generators and more via Attributes

Requirements

We aim to support versions that haven't reached their end-of-life.

How it works?

<?php

use Attributes\Serialization\Serializer;

class Person
{
    public float|int $age;
    public ?DateTime $birthday;
}

$person = new Person; 
$person->age = 30;
$person->birthday = new DateTime("2023-10-27T14:30:00Z");

$serializer = new Serializer;
$data = $serializer->serialize($person);

var_dump($data);  // array(2) { ["age"]=> int(30) ["birthday"]=> string(25) "2023-10-27T14:30:00+00:00" }

Installation

composer require attributes-php/serialization

Attributes Validation was created by André Gil and is open-sourced software licensed under the MIT license.

About

Serializes any object into a primitive type

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages