luna / vnstat
PHP wrapper for the command line app 'vnstat'
1.1.1
2016-12-23 15:02 UTC
Requires
- php: >=5.6
- nesbot/carbon: ^1.21
- symfony/process: ^2.6|~3.0
Requires (Dev)
- larapack/dd: ^1.0
- phpunit/phpunit: ^5.7
README
vnstat json output parser for PHP
Usage
use Luna\Vnstat\Vnstat; class YourClass extends Awesomeness implements Ideas { protected $interface = 'eth0'; public function runWithStaticMethod() { $jsonObject = Vnstat::get($this->interface); } public function runWithNewInstance() { $vnstat = new Vnstat($this->interface); $vnstat->run(); $rawJson = $vnstat->getJson(); $response = $vnstat->getResponse(); } }
Methods
public function Vnstat::__construct(string $interface): void
public function Vnstat::get(string $interface): \Luna\Vnstat\VnstatResponse
public function Vnstat::getResponse(): \Luna\Vnstat\VnstatResponse
public function Vnstat::setExecutablePath(string $executable): $this
public function Vnstat::getExecutablePath(): string
public function Vnstat::setJson(string $json): $this
public function Vnstat::getJson(): string
Errors/Exceptions
Throws Luna\Vnstat\Exceptions\InvalidJsonException
if the string returned by Vnstat::getJson()
was an invalid json string.
Throws Luna\Vnstat\Exceptions\ExecutableNotFoundException
if which vnstat
failed.
Throws \Symfony\Component\Process\Exception\ProcessFailedException
if vnstat --query --json -i $interface
failed.