PHP code example of iamfat / gini

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

    

iamfat / gini example snippets


// 查询所有名字以'J'开头, 爸爸的email中存在genee的用户
$users = those('users')
    ->whose('name')->beginWith('J')
    ->andWhose('father')->isIn(
        those('users')->whose('email')->contains('genee')
    );

// Client
$rpc = new \Gini\RPC('http://gini/api');
$sum = $rpc->hello->add(1, 2);

//Server
class Hello extends \Gini\Controller\API {
    public function actionAdd($a, $b) {
        return $a + $b;
    }
}

// Client
$rest = new \Gini\REST('http://localhost/rest');
$sum = $rest->post('add', ['a'=>1, 'b'=>2]);

// Server
class Hello extends \Gini\Controller\REST {
    public function postAdd($a, $b) {
        return $a + $b;
    }
}