Skip to content

DuckThom/php-vnstat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-vnstat

vnstat json output parser for PHP

StyleCI License Total Downloads

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.

About

vnstat json output parser for PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages