Skip to content

Commit 1c282da

Browse files
Readme updated, part about timeouts added to list of available parameters
1 parent 11460e8 commit 1c282da

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

README.md

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@
88

99
# RouterOS API Client
1010

11-
composer require evilfreelancer/routeros-api-php
11+
```shell
12+
composer require evilfreelancer/routeros-api-php
13+
```
1214

1315
This library is partly based on [this old project](https://github.com/BenMenking/routeros-api), but unlike it has many
14-
innovations to ease development. In addition, the project is designed
15-
to work with PHP7 in accordance with the PSR standards.
16+
innovations to ease development. In addition, the project designed
17+
to work with PHP7/8 in accordance with the PSR standards.
1618

1719
You can use this library with pre-6.43 and post-6.43 versions of
1820
RouterOS firmware, it will be detected automatically on connection stage.
1921

2022
## Minimum requirements
2123

22-
* `php` >= 7.2
24+
* `php` >= 7.2|8.0
2325
* `ext-sockets`
2426

2527
## Laravel framework support
@@ -37,7 +39,7 @@ $config = new \RouterOS\Config([
3739
$client = new \RouterOS\Client($config);
3840
```
3941

40-
Call facade and pass array of parameters to `client` method:
42+
Use the facade and pass array of parameters to `client` method:
4143

4244
```php
4345
$client = \RouterOS::client([
@@ -66,8 +68,8 @@ $client = \RouterOS::client($config);
6668
### Laravel installation
6769

6870
By default, the package will automatically register its service provider, but
69-
if you are a happy owner of Laravel version less than 5.5, then in a project, which is using your package
70-
(after composer require is done, of course), add into`providers` block of your `config/app.php`:
71+
if you are a happy owner of Laravel version less than 5.5, then in a project, which is using the package
72+
(after `composer require` is done, of course), add into`providers` block of your `config/app.php`:
7173

7274
```php
7375
'providers' => [
@@ -78,7 +80,9 @@ if you are a happy owner of Laravel version less than 5.5, then in a project, wh
7880

7981
Optionally, publish the configuration file if you want to change any defaults:
8082

81-
php artisan vendor:publish --provider="RouterOS\\Laravel\\ServiceProvider"
83+
```shell
84+
php artisan vendor:publish --provider="RouterOS\\Laravel\\ServiceProvider"
85+
```
8286

8387
## How to use
8488

@@ -92,7 +96,8 @@ use \RouterOS\Query;
9296
$client = new Client([
9397
'host' => '192.168.1.3',
9498
'user' => 'admin',
95-
'pass' => 'admin'
99+
'pass' => 'admin',
100+
'port' => 8728,
96101
]);
97102

98103
// Create "where" Query object for RouterOS
@@ -139,10 +144,11 @@ use \RouterOS\Client;
139144

140145
// Initiate client with config object
141146
$client = new Client([
142-
'host' => '192.168.1.3',
143-
'user' => 'admin',
144-
'pass' => 'admin',
145-
'ssh_port' => 22222,
147+
'host' => '192.168.1.3',
148+
'user' => 'admin',
149+
'pass' => 'admin',
150+
'ssh_port' => 22222,
151+
'ssh_timeout' => 60, // if not set then 30 seconds by default
146152
]);
147153

148154
// Execute export command via ssh
@@ -270,17 +276,21 @@ $client = new Client($config);
270276

271277
### List of available configuration parameters
272278

273-
| Parameter | Type | Default | Description |
274-
|-----------|--------|---------|-------------|
275-
| host | string | | (required) Address of Mikrotik RouterOS |
276-
| user | string | | (required) Username |
277-
| pass | string | | (required) Password |
278-
| port | int | | RouterOS API port number for access (if not set use 8728 or 8729 if SSL enabled) |
279-
| ssl | bool | false | Enable ssl support (if port is not set this parameter must change default port to ssl port) |
280-
| legacy | bool | false | Support of legacy login scheme (true - pre 6.43, false - post 6.43) |
281-
| timeout | int | 10 | Max timeout for answer from RouterOS |
282-
| attempts | int | 10 | Count of attempts to establish TCP session |
283-
| delay | int | 1 | Delay between attempts in seconds |
279+
| Parameter | Type | Default | Description |
280+
|----------------|--------|---------|-------------|
281+
| host | string | | (required) Address of Mikrotik RouterOS |
282+
| user | string | | (required) Username |
283+
| pass | string | | (required) Password |
284+
| port | int | | RouterOS API port number for access (if not set use 8728 or 8729 if SSL enabled) |
285+
| ssl | bool | false | Enable ssl support (if port is not set this parameter must change default port to ssl port) |
286+
| ssl_options | array | [details](https://github.com/EvilFreelancer/routeros-api-php/blob/master/src/Config.php#L46) | See https://www.php.net/manual/en/context.ssl.php |
287+
| legacy | bool | false | Support of legacy login scheme (true - pre 6.43, false - post 6.43) |
288+
| timeout | int | 10 | Max timeout for connecting to RouterOS (in seconds) |
289+
| socket_timeout | int | 30 | Max read timeout from RouterOS (in seconds) |
290+
| attempts | int | 10 | Count of attempts to establish TCP session |
291+
| delay | int | 1 | Delay between attempts in seconds |
292+
| ssh_port | int | 22 | Number of SSH port for exporting configuration |
293+
| ssh_timeout | int | 30 | Max timeout from router via SSH (in seconds) |
284294

285295
### How to enable support of legacy login schema (RouterOS pre-6.43)
286296

@@ -421,14 +431,14 @@ $query->equal('disabled', 'no');
421431
$query->equal('.id', 'ether1');
422432
$query->tag(4);
423433

424-
// Or
434+
// Or, RAW mode
425435

426436
$query = new Query('/interface/set');
427437
$query->add('=disabled=no');
428438
$query->add('=.id=ether1');
429439
$query->add('.tag=4');
430440

431-
// Or
441+
// Or, RAW mode in format of array
432442

433443
$query = new Query('/interface/set', [
434444
'=disabled=no',

0 commit comments

Comments
 (0)