PHP code example of luna / vnstat

1. Go to this page and download the library: Download luna/vnstat library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

luna / vnstat example snippets


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();
  }
}

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