PHP code example of phpgt / dataobject

1. Go to this page and download the library: Download phpgt/dataobject 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/ */

    

phpgt / dataobject example snippets


use Gt\DataObject\DataObjectBuilder;

// Create a new Builder and build the DataObject from an associative array.
// For example, data loaded from another remote data source.
$sourceData = [
	"id" => 105,
	"name" => "Edgar Scolmore",
	"address" => [
		"street" => "32 Trestles Lane",
		"town" => "Lensworth",
		"county" => "Scamperingshire",
		"postcode" => "SC41 8PN"
	],
];
$builder = new DataObjectBuilder();
$data = $builder->fromAssociativeArray($sourceData);

// Pass the data to a third party to process it.
ThirdParty::processData($data);

// Now we can use the data ourselves for whatever purpose:
Database::store(
	id: $data->getInt("id"),
	refname: $data->getString("name"),
);