PHP code example of heyanlong / idiot

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

    

heyanlong / idiot example snippets



use Idiot\Service;
use Idiot\Type;

$options = [
    "conn" => "127.0.0.1:2181",
    "path" => "com.alibaba.dubbo.service.user",
    "version" => "1.0.0"
];

$service = new Service($options);
$data = $service->invoke('getUserById', [951]);

$service->invoke("getUserById", [Type::int(951)]);

$service->invoke("getUserByName", ["Lorne"]);

// you can also
$service->invoke("getUserByName", [Type::string("Lorne")]);

Type::object("com.alibaba.dubbo.parameter.user", [
    "age": 20,
    "sex": "male"
]);

$service->invoke("complex", [
    Type::int(17263),
    Type::boolean(false),
    Type::string("male"),
    Type::double(16.25),
    Type::object("java.math.BigDecimal", 2367.299)
]);

Type::short($value);
Type::int($value);
Type::integer($value);
Type::long($value);
Type::float($value);
Type::double($value);
Type::bool($value);
Type::boolean($value);
Type::string($value);
Type::object($class_name, $properties);
bash
$ sudo apt-get install php-pear php5-dev make  
$ sudo pecl install zookeeper