PHP code example of coagus / php-api-builder

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

    

coagus / php-api-builder example snippets



 = new ApiBuilder\API('Services');
$api->run();


namespace Services;

class Demo
{
  public function get()
  {
    success('Hello World!');
  }

  public function postHello()
  {
    $input = getInput();
    success('Hello ' . $input['name'] . '!');
  }
}


namespace DemoApi\Entities;

use ApiBuilder\ORM\Entity;

class User extends Entity
{
  public $id;
  public $name;
  public $username;
  public $password;
  public $email;
  public $active;
  public $roleId;
}
bash
composer 
json
{
  "gus/php-api-builder": "v1.0.0"
  }
  "autoload": {
    "psr-4": {
      "Services\\": "services/"
    }
  }
}