PHP code example of atiksoftware / php-class-schema-merger

1. Go to this page and download the library: Download atiksoftware/php-class-schema-merger 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/ */

    

atiksoftware / php-class-schema-merger example snippets




use \Atiksoftware\Schema\Merger;
$schemaMerger = new Merger();

    $schemaMerger->setSchema([
        "_id" => [
            "_type"    => "string",
            "_default" => "5f5e100"
        ],
        "name" => [
            "_type"    => "string",
            "_default" => "Yeni başlık",
            "_format"  => "fullname"
        ],
        "title" => [
            "_type"    => "array",
            "TR" => [
                "_type"    => "string",
                "_default" => "Türkçe Başlık",
                "_format"  => "upfirst"
            ],
            "EN" => [
                "_type"    => "string",
                "_default" => "English Title"
            ],
        ], 
        "tags" => [
            "_type"    => "array",
            "_default" => [ ],
        ],
        "date" => [
            "_type"    => "array",
            "edit" => [
                "_type"    => "integer",
                "_default" => time()
            ]
        ],
        "admin" => [
            "_type"    => "boolean",
            "_default" => false
        ],
        "age" => [
            "_type"    => "int",
            "_default" => 15,
            "_min"     => 5,
            "_max"     => 35,
        ],
    ]);

    $item = [
        "name"  => "Mansur atik",
        "title" => [
            "TR" => "Nasıl"
        ],
        "admin" => 1,
        "age"   => 434
    ];

    $result = $schemaMerger->Migrate($item);
    var_dump($result);