PHP code example of dozer111 / serialize

1. Go to this page and download the library: Download dozer111/serialize library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dozer111 / serialize example snippets


use dozer111\serializer\SerializeFactory;

# ..........

$testData = new SomeYourObject();


# you can get json data like this 
$data = (new SerializeFactory('json'))->serialize($testData);
# or using one of SerializeFactory constants
/*
$data = (new SerializeFactory(SerializeFactory::SERIALIZER_JSON))
            ->serialize($testData);
*/

use dozer111\serializer\SerializeFactory;

# ..........

$testData = new SomeYourObject();
$data = (new SerializeFactory(SerializeFactory::SERIALIZER_JSON))
            ->serialize($testData,SerializeFactory::SERIALIZE_PROTECTED);

use dozer111\serializer\SerializeFactory;
use xxx\yyy\DummySerialize;

# ..........

$testData = new SomeYourObject();
$yourSerializer = DummySerialize::class;

$data = (new SerializeFactory($yourSerializer))
            ->serialize($testData);