PHP code example of axonbase / sdk

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

    

axonbase / sdk example snippets




xonBase\Axon;

$axon = Axon::connect('ws://127.0.0.1:8000/rpc/ws');
$axon->use('test', 'dev');
$axon->query('CREATE person CONTENT {name: "Ana", age: 30}');

$rows = $axon->select('person');
var_dump($rows);

$axon->close();

$axon = Axon::connect('ws://127.0.0.1:8000/rpc/ws');
$axon->use('test', 'dev');
$token = $axon->signin('root', 'root');
$axon->authenticate($token);
// Ou: $axon->authenticate(getenv('AXON_TOKEN'));

$rows = $axon->query('SELECT * FROM person');
$axon->close();

use AxonBase\Migration\Migrator;

$migrator = new Migrator($axon);
$migrator->ensureTable();
$applied = $migrator->up(__DIR__ . '/migrations');
$status = $migrator->status(__DIR__ . '/migrations');