Example #1
0
 /**
  * @param PhrestSDK $sdk
  * @param string    $namespace
  */
 public function __construct(PhrestSDK $sdk, $namespace = 'SDK')
 {
     $this->sdk = $sdk;
     $this->config = $this->sdk->app->di->get('config');
     Files::$outputDir = $this->sdk->srcDir;
     Generator::$namespace = rtrim($namespace, '\\');
 }
Example #2
0
 /**
  * @param PhrestSDK $sdk
  * @param Config    $config
  * @param string    $namespace
  */
 public function __construct(PhrestSDK $sdk, $config, $namespace = 'SDK')
 {
     $this->sdk = $sdk;
     $this->config = $config;
     self::$name = $config->name;
     Files::$outputDir = rtrim($this->sdk->srcDir, '/');
     Generator::$namespace = rtrim($namespace, '\\');
     if (getenv('FORCE')) {
         self::$force = true;
     }
 }
Example #3
0
<?php

use Phalcon\Config\Adapter\Yaml;
use Phrest\API\PhrestAPI;
use Phrest\SDK\Generator;
use Phrest\SDK\PhrestSDK;
use Phrest\Skeleton\Common\APIDI;
use Phrest\Skeleton\v1\Requests\Users\CreateUserRequest;
include dirname(__DIR__) . '/vendor/autoload.php';
$srcDir = dirname(__DIR__) . '/src/';
$sdk = new PhrestSDK($srcDir);
$generator = new Generator($sdk, new Yaml($srcDir . '/Config/build.yaml'), 'Phrest\\Skeleton');
if (in_array('--force', $argv)) {
    //This will cause the generator to overwrite files
    //By default it only adds if a file/function/property doesn't exist
    Generator::$force = true;
}
if (in_array('--test', $argv)) {
    $di = new APIDI();
    $di->setShared('sdk', $sdk);
    $app = new PhrestAPI($di, $srcDir);
    //Use internal calls
    $sdk->setApp($app);
    //Using constructor
    $responses[] = (new CreateUserRequest('john', '*****@*****.**', 'pass'))->create();
    //Using setters
    $responses[] = (new CreateUserRequest())->setName('jane')->setEmail('*****@*****.**')->setPassword('pass')->create();
    //Using properties
    $request = new CreateUserRequest();
    $request->name = 'james';
    $request->email = '*****@*****.**';