1. Go to this page and download the library: Download indatus/trucker 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/ */
indatus / trucker example snippets
class Product extends Trucker\Resource\Model {} //create a class to use
$p = new Product(['name' => 'My Test Product']);
$success = $p->save(); //create a new entity
$found = Product::find(1); //find an existing entity
$found->name = 'New Product Name';
$success = $found->save(); //update an entity
$success = $found->destroy(); //destroy an entity
$results = Product::all(); //find a collection
$attributes = ['name' => 'XYZ Headphones', 'vendor' => 'Acme', 'price' => '10000'];
//pass attributes to the constructor
$p = new Product($attributes);
//or use the fill() method
$p = new Product;
$p->fill($attributes);
//get the attributes back if you want to see them
print_r($p->attributes());
// => ['name' => 'XYZ Headphones', 'vendor' => 'Acme', 'price' => '10000']
//maybe you want to see a particular property
echo $p->name; // => XYZ Headphones
//or modify a property
$p->name = "ABC Headphones";
//save the object over the API. The save() method will create or update
//the object as necessary. It returns true or false based on success.
$success = $p->save();
if ($success) {
//the identity property is set back on the object after it is created
echo "Saved product '{$p->name}' with ID: ". $p->getId();
} else {
//maybe you want to print out the errors if there were some
echo "Errors: ". implode(", ", $p->errors());
// => ['Category is