PHP code example of akvo / akvo-flow-php-sdk

1. Go to this page and download the library: Download akvo/akvo-flow-php-sdk 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/ */

    

akvo / akvo-flow-php-sdk example snippets


use Akvo\Models\Survey;
use Akvo\Models\Answer;

public function surveyAndForms(Survey $surveys)
{
  return $surveys->with('forms');
}

public function answerAndForm(Answer $answer)
{
  return $answer->load('question.form');
}

Namespace App\Model;

use Illuminate\Support\Str;
use Akvo\Models\Survey as AkvoSurvey;

class Survey extends AkvoSurvey
{
  $protected $appends = ['short'];
  
  public function getShortAttribute()
  {
        $text = trim(preg_replace('!\s+-!', ' -', $this->name));
        $text = Str::beforeLast($text, ' (');
        return Str::upper($text);
  }
}

sh
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '8a6138e2a05a8c28539c9f0fb361159823655d7ad2deecb371b04a83966c61223adc522b0189079e3e9e277cd72b8897') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
json
{
    "kvo/akvo-flow-php-sdk": "1.0.*"
    }
}