当前位置: 首页>>代码示例>>PHP>>正文


PHP Terminus类代码示例

本文整理汇总了PHP中Terminus的典型用法代码示例。如果您正苦于以下问题:PHP Terminus类的具体用法?PHP Terminus怎么用?PHP Terminus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Terminus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __invoke

 /**
  * Invoke `wp` commands on a Pantheon development site
  *
  * <commands>...
  * : The WP-CLI commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional WP-CLI flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 function __invoke($args, $assoc_args)
 {
     $environment = Input::env($assoc_args);
     $sites = new Sites();
     $site = $sites->get(Input::sitename($assoc_args));
     if (!$site) {
         Terminus::error("Command could not be completed. Unknown site specified.");
         exit;
     }
     # see https://github.com/pantheon-systems/titan-mt/blob/master/dashboardng/app/workshops/site/models/environment.coffee
     $server = array('user' => "{$environment}.{$site->get('id')}", 'host' => "appserver.{$environment}.{$site->get('id')}.drush.in", 'port' => '2222');
     if (strpos(TERMINUS_HOST, 'onebox') !== FALSE) {
         $server['user'] = "appserver.{$environment}.{$site->get('id')}";
         $server['host'] = TERMINUS_HOST;
     }
     # Sanitize assoc args so we don't try to pass our own flags.
     # TODO: DRY this out?
     unset($assoc_args['site']);
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     # Create user-friendly output
     $command = implode($args, ' ');
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}=" . escapeshellarg($v) . ' ';
         } else {
             $flags .= "--{$k} ";
         }
     }
     $this->logger->info("Running wp %s %s on %s-%s", array($command, $flags, $site->get('name'), $environment));
     $this->send_command($server, 'wp', $args, $assoc_args);
 }
开发者ID:newtoid,项目名称:cli,代码行数:50,代码来源:wp.php

示例2: sites

 /**
  * List an organizations sites
  *
  * ## OPTIONS
  *
  * [--org=<org>]
  * : Organization name or Id
  *
  * [--add=<site>]
  * : Site to add to organization
  *
  * [--remove=<site>]
  * : Site to remove from organization
  *
  * @subcommand sites
  *
  */
 public function sites($args, $assoc_args)
 {
     $orgs = array();
     $user = new User();
     foreach ($user->organizations() as $id => $org) {
         $orgs[$id] = $org->name;
     }
     if (!isset($assoc_args['org']) or empty($assoc_args['org'])) {
         $selected_org = Terminus::menu($orgs, false, "Choose an organization");
     } else {
         $selected_org = $assoc_args['org'];
     }
     $org = new Organization($selected_org);
     if (isset($assoc_args['add'])) {
         $add = SiteFactory::instance(Input::site($assoc_args, 'add'));
         Terminus::confirm("Are you sure you want to add %s to %s ?", $assoc_args, array($add->getName(), $org->name));
         $org->addSite($add);
         Terminus::success("Added site!");
         return true;
     }
     if (isset($assoc_args['remove'])) {
         $remove = SiteFactory::instance(Input::site($assoc_args, 'remove'));
         Terminus::confirm("Are you sure you want to remove %s to %s ?", $assoc_args, array($remove->getName(), $org->name));
         $org->removeSite($remove);
         Terminus::success("Removed site!");
         return true;
     }
     $sites = $org->getSites();
     $data = array();
     foreach ($sites as $site) {
         $data[] = array('name' => $site->site->name, 'service level' => isset($site->site->service_level) ? $site->site->service_level : '', 'framework' => isset($site->site->framework) ? $site->site->framework : '', 'created' => date('Y-m-d H:i:s', $site->site->created));
     }
     $this->handleDisplay($data);
 }
开发者ID:slivermon,项目名称:cli,代码行数:51,代码来源:organizations.php

示例3: request

 /**
  * Make a request to the Pantheon API
  *
  * @param [string] $realm   Permissions realm for data request (e.g. user,
  *   site organization, etc. Can also be "public" to simply pull read-only
  *   data that is not privileged.
  * @param [string] $uuid    The UUID of the item in the realm to access
  * @param [string] $path    API path (URL)
  * @param [string] $method  HTTP method to use
  * @param [mixed]  $options A native PHP data structure (e.g. int, string,
  *   array, or stdClass) to be sent along with the request
  * @return [array] $data
  */
 public static function request($realm, $uuid, $path = false, $method = 'GET', $options = null)
 {
     if (!in_array($realm, array('login', 'user', 'public'))) {
         Auth::loggedIn();
     }
     try {
         $cache = Terminus::get_cache();
         if (!in_array($realm, array('login', 'user'))) {
             $options['cookies'] = array('X-Pantheon-Session' => Session::getValue('session'));
             $options['verify'] = false;
         }
         $url = Endpoint::get(array('realm' => $realm, 'uuid' => $uuid, 'path' => $path));
         if (Terminus::get_config('debug')) {
             Terminus::log('debug', 'Request URL: ' . $url);
         }
         $resp = Request::send($url, $method, $options);
         $json = $resp->getBody(true);
         $data = array('info' => $resp->getInfo(), 'headers' => $resp->getRawHeaders(), 'json' => $json, 'data' => json_decode($json), 'status_code' => $resp->getStatusCode());
         return $data;
     } catch (Guzzle\Http\Exception\BadResponseException $e) {
         $response = $e->getResponse();
         throw new TerminusException($response->getBody(true));
     } catch (Guzzle\Http\Exception\HttpException $e) {
         $request = $e->getRequest();
         $sanitized_request = TerminusCommand::stripSensitiveData((string) $request, TerminusCommand::$blacklist);
         throw new TerminusException('API Request Error. {msg} - Request: {req}', array('req' => $sanitized_request, 'msg' => $e->getMessage()));
     } catch (Exception $e) {
         throw new TerminusException('API Request Error: {msg}', array('msg' => $e->getMessage()));
     }
 }
开发者ID:nataliejeremy,项目名称:cli,代码行数:43,代码来源:class-terminus-command.php

示例4: _url

 protected function _url($args, $callback)
 {
     foreach ($args as $obj_id) {
         $object = $this->fetcher->get_check($obj_id);
         \Terminus::line($callback($object->{$this->obj_id_key}));
     }
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:7,代码来源:CommandWithDBObject.php

示例5: sites

 /**
  * List an organization's sites
  *
  * ## OPTIONS
  *
  * [--org=<id>]
  * : Organization id
  *
  * [--tag=<tag>]
  * : Tag name to filter sites list by
  *
  * [--add=<site>]
  * : Site to add to organization
  *
  * [--remove=<site>]
  * : Site to remove from organization
  *
  * @subcommand sites
  *
  */
 public function sites($args, $assoc_args)
 {
     $org_id = Input::orgid($assoc_args, 'org', null, array('allow_none' => false));
     $org = new Organization($org_id);
     if (isset($assoc_args['add'])) {
         $add = SiteFactory::instance(Input::sitename($assoc_args, 'add'));
         Terminus::confirm("Are you sure you want to add %s to %s ?", $assoc_args, array($add->getName(), $org->name));
         $org->addSite($add);
         Terminus::success("Added site!");
         return true;
     }
     if (isset($assoc_args['remove'])) {
         $remove = SiteFactory::instance(Input::sitename($assoc_args, 'remove'));
         Terminus::confirm("Are you sure you want to remove %s to %s ?", $assoc_args, array($remove->getName(), $org->name));
         $org->removeSite($remove);
         Terminus::success("Removed site!");
         return true;
     }
     $org->siteMemberships->fetch();
     $memberships = $org->siteMemberships->all();
     foreach ($memberships as $membership) {
         if (isset($assoc_args['tag']) && !in_array($assoc_args['tag'], $membership->get('tags'))) {
             continue;
         }
         $site = $membership->get('site');
         $data[] = array('name' => $site->name, 'id' => $site->id, 'service_level' => $site->service_level, 'framework' => $site->framework, 'created' => date('Y-m-d H:i:s', $site->created), 'tags' => $membership->get('tags'));
     }
     $this->handleDisplay($data);
 }
开发者ID:skyywalk3rr,项目名称:cli,代码行数:49,代码来源:organizations.php

示例6: login

 /**
  * Log in as a user
  *
  *  ## OPTIONS
  * [<email>]
  * : Email address to log in as.
  *
  * [--password=<value>]
  * : Log in non-interactively with this password. Useful for automation.
  *
  * [--machine-token=<value>]
  * : Authenticate using an Auth0 token
  *
  * [--debug]
  * : dump call information when logging in.
  */
 public function login($args, $assoc_args)
 {
     // Try to login using a machine token, if provided.
     if (isset($assoc_args['machine-token']) || empty($args) && isset($_SERVER['TERMINUS_MACHINE_TOKEN'])) {
         $token = $_SERVER['TERMINUS_MACHINE_TOKEN'];
         if (isset($assoc_args['machine-token'])) {
             $token = $assoc_args['machine-token'];
         }
         $this->auth->logInViaMachineToken($token);
     } else {
         // Otherwise, do a normal email/password-based login.
         if (empty($args)) {
             if (isset($_SERVER['TERMINUS_USER'])) {
                 $email = $_SERVER['TERMINUS_USER'];
             } else {
                 $email = Terminus::prompt('Your email address?', null);
             }
         } else {
             $email = $args[0];
         }
         if (isset($assoc_args['password'])) {
             $password = $assoc_args['password'];
         } else {
             $password = Terminus::promptSecret('Your dashboard password (input will not be shown)');
         }
         $this->auth->logInViaUsernameAndPassword($email, $password);
     }
     $this->log()->debug(get_defined_vars());
     Terminus::launchSelf('art', array('fist'));
 }
开发者ID:blueprintmrk,项目名称:cli,代码行数:46,代码来源:auth.php

示例7: send_command

 protected function send_command($server, $remote_exec, $args, $assoc_args)
 {
     # unset CLI args
     unset($assoc_args['site']);
     $remote_cmd = $remote_exec . ' ';
     foreach ($args as $arg) {
         $remote_cmd .= escapeshellarg($arg) . ' ';
     }
     foreach ($assoc_args as $key => $value) {
         if ($value != 1) {
             $remote_cmd .= ' --' . $key . '=' . escapeshellarg($value);
         } else {
             $remote_cmd .= ' --' . $key;
         }
     }
     $cmd = 'ssh -T ' . $server['user'] . '@' . $server['host'] . ' -p ' . $server['port'] . ' -o "AddressFamily inet"' . " " . escapeshellarg($remote_cmd);
     if (\Terminus::get_config('silent')) {
         ob_start();
     }
     passthru($cmd, $exit_code);
     if (\Terminus::get_config('silent')) {
         $this->logger->info(ob_get_clean());
     }
     if ($exit_code == 255) {
         $this->logger->error("Failed to connect. Check your credentials, and that you are specifying a valid environment.");
     }
     return $exit_code;
 }
开发者ID:newtoid,项目名称:cli,代码行数:28,代码来源:CommandWithSSH.php

示例8: __invoke

 /**
  * Invoke `drush` commands on a Pantheon development site
  *
  * <commands>...
  * : The Drush commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional Drush flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 function __invoke($args, $assoc_args)
 {
     $environment = Input::env($assoc_args);
     $sites = new Sites();
     $site = $sites->get(Input::sitename($assoc_args));
     if (!$site) {
         Terminus::error("Command could not be completed. Unknown site specified.");
         exit;
     }
     $server = array('user' => "{$environment}.{$site->get('id')}", 'host' => "appserver.{$environment}.{$site->get('id')}.drush.in", 'port' => '2222');
     if (strpos(TERMINUS_HOST, 'onebox') !== FALSE) {
         $server['user'] = "appserver.{$environment}.{$site->get('id')}";
         $server['host'] = TERMINUS_HOST;
     }
     # Sanitize assoc args so we don't try to pass our own flags.
     # TODO: DRY this out?
     unset($assoc_args['site']);
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     # Create user-friendly output
     $command = implode($args, ' ');
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}={$v} ";
         } else {
             $flags .= "--{$k} ";
         }
     }
     $this->logger->info("Running drush %s %s on %s-%s", array($command, $flags, $site->get('name'), $environment));
     $this->send_command($server, 'drush', $args, $assoc_args);
 }
开发者ID:newtoid,项目名称:cli,代码行数:49,代码来源:drush.php

示例9: __construct

 public function __construct($filename, $delimiter = ',')
 {
     $this->filePointer = fopen($filename, 'r');
     if (!$this->filePointer) {
         \Terminus::error(sprintf('Could not open file: %s', $filename));
     }
     $this->delimiter = $delimiter;
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:8,代码来源:CSV.php

示例10: testRunCommand

 public function testRunCommand()
 {
     $runner = \Terminus::getRunner();
     $this->assertInstanceOf('Terminus\\Runner', $runner);
     $args = array('site');
     $assoc_args = array('site' => 'phpunittest');
     $return = $runner->runCommand($args, $assoc_args);
     $this->assertNull($return);
 }
开发者ID:serundeputy,项目名称:cli,代码行数:9,代码来源:test-runner.php

示例11: __invoke

 /**
  * View Pantheon artwork
  *
  * ## Options
  *
  * fist
  *
  * unicorn
  *
  * druplicon
  *
  * wordpress
  */
 function __invoke($args, $assoc_args)
 {
     $artwork = array_shift($args) ?: array_rand($this->works);
     if (!empty($artwork) && array_key_exists($artwork, $this->works)) {
         echo Terminus::colorize("%g" . base64_decode($this->works[$artwork]) . "%n") . "\n";
     } else {
         throw new TerminusException("No formula for requested artwork");
     }
 }
开发者ID:nataliejeremy,项目名称:cli,代码行数:22,代码来源:art.php

示例12: init_config

 private function init_config()
 {
     $configurator = \Terminus::get_configurator();
     list($args, $assoc_args, $runtime_config) = $configurator->parse_args(array_slice($GLOBALS['argv'], 1));
     $this->arguments = $args;
     $this->assoc_args = $assoc_args;
     $configurator->merge_array($runtime_config);
     list($this->config, $this->extra_config) = $configurator->to_array();
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:9,代码来源:Runner.php

示例13: __invoke

 /**
  * Commands specific to an environment
  *
  * <commands>...
  * [--site=<value>]
  * : specify the site on which the command should be performed
  * [--env=<value>]
  * : Specificy the environment of a site previously set with --site=
  *
  * [--<flag>=<value>]
  * : Additional argument flag(s) to pass in to the command.
  */
 function __invoke(array $args, array $assoc_args)
 {
     if (empty($args)) {
         Terminus::error("You need to specify a task to perform, site and environment on which to perform.");
     } else {
         $this->_handleFuncArg($args, $assoc_args);
         $this->_handleSiteArg($args, $assoc_args);
     }
     $this->_execute($args, $assoc_args);
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:22,代码来源:code.php

示例14: testCheckForUpdate

 /**
  * @vcr utils#checkCurrentVersion
  */
 public function testCheckForUpdate()
 {
     $log_file = getLogFileName();
     setOutputDestination($log_file);
     Terminus::getCache()->putData('latest_release', ['check_date' => strtotime('8 days ago')]);
     Utils\checkForUpdate();
     $file_contents = explode("\n", file_get_contents($log_file));
     $this->assertFalse(strpos(array_pop($file_contents), 'An update to Terminus is available.'));
     resetOutputDestination($log_file);
 }
开发者ID:karudonaldson,项目名称:terminus,代码行数:13,代码来源:test-utils.php

示例15: getArgsKey

 static function getArgsKey($args)
 {
     // strip UUIDs
     $string = preg_replace('#https://dashboard.getpantheon.com/api/(sites|users|ogranizations)\\/(.*)\\/(.+)$#s', '$1/$3', $args[0]);
     $key = sprintf('%s%s', $args[1], strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $string))));
     if (\Terminus::get_config('debug')) {
         \Terminus\Loggers\Regular::debug(var_export($args, 1));
         \Terminus\Loggers\Regular::debug($key);
     }
     return $key;
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:11,代码来源:Fixtures.php


注:本文中的Terminus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。