PHP code example of betalabs / engine-phpsdk

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

    

betalabs / engine-phpsdk example snippets


$get = \Betalabs\Engine\Request::get();
$response = $get->send('path/to/api'); // ['data' => [...]]
$statusCode = $get->statusCode(); // 200

class Object {

  protected $request;
  
  public __construct(\Betalabs\Engine\Request $request)
  {
    $this->request = $request;
  }
  
  public function get()
  {
    $get = $this->request->get();
    $response = $get->send('path/to/api'); // ['data' => [...]]
    $statusCode = $get->statusCode(); // 200
  }

}

$post = \Betalabs\Engine\Request::post();
$post->send(
  'path/to/api',
  [
    'parameter1' => 'value 1',
    'parameter2' => 'value 2',
    // ...
  ]
);

$get->setEndpointSuffix(null)->send('path/to/api'); // http://engine.url/path/to/api

 $get = \Betalabs\Engine\Request::get();
 $response = $get
  ->mustNotAuthorize()
  ->send('path/to/api');

public function permissions(\Betalabs\Engine\Permissions\Register $register)
{

    $register->add(new \Betalabs\Engine\Permissions\Permission(
        'permission-0-name',
        'Permission #0 name',
        'Permission #0 description'
    ));

    $register->add(new \Betalabs\Engine\Permissions\Permission(
        'permission-1-name',
        'Permission #1 name',
        'Permission #1 description'
    ));

}

public function run()
{

    // Migration process

    return new \Betalabs\Engine\Requests\BootResponse(
        true,
        'Success!'
    );
    
}

public function run()
{

    // Genesis process

    return new \Betalabs\Engine\Requests\BootResponse(
        true,
        'Success!'
    );
    
}