/** * */ public function call($verb, $host, $port, $uri, $headers = null, $query = null, $body = null, $statusCode = null) { // Fix headers, query and body $headers = \z\conf($headers); $query = \z\conf($query); if (is_null($body) === true) { $body = ''; } // Body must be a string if (is_string($body) === false) { \z\e(EXCEPTION_HTTP_BODY_NOT_VALID, ['body' => json_encode($body, true), 'type' => gettype($body)]); } // Build the HTTP client $client = new \GuzzleHttp\Client(['base_url' => $host]); // Build the request $request = $client->createRequest($verb, $uri, ['exceptions' => false]); // Setup the request $request->setPort($port); $request->setHeaders($headers); $request->setQuery($query); $request->setBody(\GuzzleHttp\Stream\Stream::factory($body)); // Log \z\logger()->debug($request); // Send the request $response = $client->send($request); // Log \z\logger()->debug($response); // Did it succeed? if (is_null($statusCode) === false && (int) $statusCode !== (int) $response->getStatusCode()) { \z\e(EXCEPTION_HTTP_STATUS_CODE_NOT_VALID, ['expected' => $statusCode, 'actual' => $response->getStatusCode(), 'request' => $request->__toString(), 'response' => $response->__toString()]); } // Build the result $result = $response->getBody(); return $result; }
/** * */ public function applyMigration($origin = null, $destination = null) { /* Goal is to migrate from A to B Eventually the application will be in version B So we need to find migrations between A and B, and apply upgrade() for each */ $migrations = []; $migrations[] = new \Splio\Appforge\Migrations\Migration_0000(); foreach ($migrations as $migration) { // Log \z\logger()->notice('Applying migration ' . get_class($migration) . '...'); // $migration->upgrade(); } }