PHP code example of komodohq / siesta

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

    

komodohq / siesta example snippets


public static function populate($item)
{
    $reflect  = new ReflectionClass($class);
    return $reflect->newInstanceArgs($item);
}
 php

class User {

    use Siesta\Siesta;

    private static $siestaConfig = [
            "url" => "http://localhost:9999",
            "endpoint" => "users"
        ];

    // constructor takes assoc array of properties
    function __construct($data) {
        $this->_id = $data['id'];
        $this->name = $data['name'];
    }
}

$users = User::find();

 php
User::findById($id[, $options]);

User::findById(1);
User::findById(1, ["endpoint" => "administrators"]);
 php
$user->update($data[, $options]);

$user->update(["location" => "Newcastle Upon Tyne"]);
$user->update(["location" => "Newcastle Upon Tyne"], ["endpoint" => "administrators"]);
 php
$user->save([$options]);

$user->save();
$user->save(["endpoint" => "administrators"]);
 php
$user->delete([$options]);

$user->delete(["endpoint" => "administarots"]);
 php
public function toArray()
{
    return get_object_vars($this);
}
 php
public function setValue($property, $value)
{
    $this->$property = $value;
}
 php
public function setValue($property, $value)
{
    if ($property == 'registered') {
        $this->$property = strtotime($value);
    } else {
        $this->$property = $value;
    }
}
 php
$e->getResponse();

$ php -S localhost:9999 ./tests/index.php