PHP code example of laocc / rpc

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

    

laocc / rpc example snippets




namespace application\rpc\controllers;

use laocc\rpc\Controller;

class _Base extends Controller
{
    public function _main()
    {
    
    }
}

    # 此方法在exp的Controller中已存在,可直接调用
    protected function rpc(string $uri, array $data = [])
    {
        $url = explode(':', $uri);
        $rpc = new Rpc($url[0]);
        $check = $rpc->post($url[1], $data);
        if (is_string($check)) return $check;
        return $check['data'];
    }


    $check = $this->rpc('account:/admin/check', ['id' => $this->adminID]);
    print_r($check);

server    {
    listen 44380;
    server_name account.esp;
    index index.php;
    root /home/account/public/rpc;