From 4dcdcf8cb1cab26d397337025e2334029af7cc4b Mon Sep 17 00:00:00 2001 From: Paul Rock Date: Wed, 6 Feb 2019 04:17:34 +0300 Subject: [PATCH] docs updated --- README.md | 38 ++++++++++++++++++++++++++++++-------- examples/ip_address_print.php | 16 ++++++---------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b3d9486..f1a6834 100644 --- a/README.md +++ b/README.md @@ -35,15 +35,12 @@ use \RouterOS\Config; use \RouterOS\Client; use \RouterOS\Query; -// Create object of class and set parameters -$config = - (new Config()) - ->set('host', '192.168.1.3') - ->set('user', 'admin') - ->set('pass', 'admin'); - // Initiate client with config object -$client = new Client($config); +$client = new Client([ + 'host' => '192.168.1.3', + 'user' => 'admin', + 'pass' => 'admin' +]); // Build query $query = new Query('/ip/address/print'); @@ -61,6 +58,10 @@ You can simplify your code and send then read from socket in one line: ```php $response = $client->write($query)->read(); var_dump($response); + +// Single method analog of line above is +$response = $client->wr($query); +var_dump($response); ``` By the way, you can send few queries to your router without result: @@ -75,6 +76,13 @@ $client->write($query1)->write($query2)->write($query3); // Enable config class use \RouterOS\Config; +// Create object of config class in one call +$config = new Config([ + 'host' => '192.168.1.3', + 'user' => 'admin', + 'pass' => 'admin' +]); + // Create object of class $config = new Config(); @@ -90,6 +98,20 @@ $config ->set('pass', 'admin'); ``` +Or you can just create preconfigured client object with all +required settings: + +```php +// Enable config class +use \RouterOS\Client; + +$client = new Client([ + 'host' => '192.168.1.3', + 'user' => 'admin', + 'pass' => 'admin' +]); +``` + #### List of available configuration parameters | Parameter | Type | Default | Description | diff --git a/examples/ip_address_print.php b/examples/ip_address_print.php index dccc027..50b9b6e 100644 --- a/examples/ip_address_print.php +++ b/examples/ip_address_print.php @@ -3,20 +3,16 @@ require_once __DIR__ . '/../vendor/autoload.php'; error_reporting(E_ALL); -use \RouterOS\Config; use \RouterOS\Client; use \RouterOS\Query; -// Create config object with parameters -$config = - (new Config()) - ->set('timeout', 1) - ->set('host', '127.0.0.1') - ->set('user', 'admin') - ->set('pass', 'admin'); - // Initiate client with config object -$client = new Client($config); +$client = new Client([ + 'timeout' => 1, + 'host' => '127.0.0.1', + 'user' => 'admin', + 'pass' => 'admin' +]); // Build query $query = new Query('/ip/address/print');