PHP code example of balambasik / client-server

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

    

balambasik / client-server example snippets




erver = new \Balambasik\ClientServer\ApiServer([
    "secret" => "cdd9ea63ace1f9873f3b510c2f613ab7c5538337",
    "enable_logs" => true,
]);

$ApiServer->on("actionName", function($requestdata){
    $this->exitJson($requestdata);
});

$array = [1, 2, 3, 4, 5];

$ApiServer->on("actionName2", function($requestdata) use ($array) {
    $this->exitJson($requestdata);
    print_r($array);
});



lient = new \Balambasik\ClientServer\ApiClient([
    "api_url" => "http://client-server/example-server.php",
    "secret" => "cdd9ea63ace1f9873f3b510c2f613ab7c5538337"
]);

$response = $ApiClient->request("actionName", [
    "foo" => "foo",
    "bar" => "bar"
]);

var_export($response->get());
var_export($response->getArray());
var_export($response->getArray('key'));