nioc / synology-srm-php-api
API wrapper for Synology Router Manager (SRM)
Requires
- analog/analog: ^1.0
This package is auto-updated.
Last update: 2024-10-28 01:28:00 UTC
README
API wrapper for Synology Router Manager (SRM).
Key features
- get WAN status,
- get network utilization,
- get devices with status, IP, etc... ,
- get wifi devices with link quality, signal strength, max rate, band used, etc... ,
- get devices traffic usage (live, day, week, month),
- get mesh nodes with status, connected devices, etc... ,
- get wake-on-lan devices,
- get access control groups with devices, online status, etc... ,
- add wake-on-lan on a device,
- wake-on-lan a device.
Installation
To install with composer:
composer require nioc/synology-srm-php-api
Or download latest release zip archive,
Usage
Create client
Create a simple client
$client = new SrmClient(null, $username, $password, $hostname, $port, $https, false);
Create a client with session keeped
If you can store session id, you can pass it value to constructor. if value is null
, client will execute a login request.
$client = new SrmClient(null, $username, $password, $hostname, $port, $https, true, $sid);
To retrieve session id value in order to store it:
$sid = $client->getSid();
Create a client with logger
Constructor first parameter is LoggerInterface
, allowing you to use any PSR-3 compliant logger library (like Monolog or Analog).
Following a basic console logger with Analog:
use Analog\Logger; use Analog\Handler\EchoConsole; $logger = new Logger; Analog::$format = "%s - %s - %s - %s\n"; $logger->handler( Analog\Handler\Threshold::init( Analog\Handler\LevelName::init( EchoConsole::init() ), Analog::INFO ) ); $client = new SrmClient($logger, $username, $password, $hostname, $port, $https, true, $sid);
Get devices, mesh, traffic, ...
Simply call the requested client method, exemple with traffic:
$devicesTraffic = $client->getTraffic('live');
You can see a full exemple here.
Versioning
This library is maintained under the semantic versioning guidelines.
See the releases on this repository for changelog.
Contributing
If you have a suggestion, please submit a feature request. Pull requests are welcomed.
Credits
- Nioc - Initial work
See also the list of contributors to this project.
License
This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details