• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Terminus类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: show_usage

 function show_usage()
 {
     $methods = $this->get_subcommands();
     $i = 0;
     foreach ($methods as $name => $subcommand) {
         $prefix = 0 == $i++ ? 'usage: ' : '   or: ';
         \Terminus::line($subcommand->get_usage($prefix));
     }
     \Terminus::line();
     \Terminus::line("See 'terminus help {$this->name} <command>' for more information on a specific command.");
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:11,代码来源:CompositeCommand.php


示例17: get_many

 /**
  * @param array The raw CLI arguments
  * @return array The list of found items
  */
 public function get_many($args)
 {
     $items = array();
     foreach ($args as $arg) {
         $item = $this->get($arg);
         if ($item) {
             $items[] = $item;
         } else {
             \Terminus::warning(sprintf($this->msg, $arg));
         }
     }
     return $items;
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:17,代码来源:Base.php


示例18: __construct

 /**
  * The License singleton
  *
  * @var License
  */
 function __construct()
 {
     $whmcs = Application::getinstance();
     $this->licensekey = $whmcs->get_license_key();
     $this->localkey = $whmcs->get_config('License');
     $this->salt = sha1('WHMCS' . $whmcs->get_config('Version') . 'TFB' . $whmcs->get_hash());
     $this->date = date('Ymd');
     $this->decodeLocalOnce();
     if (isset($_GET['forceremote'])) {
         $this->forceRemoteCheck();
         Terminus::getinstance()->doExit();
     }
 }
开发者ID:MarcelaGotta,项目名称:Webty,代码行数:18,代码来源:License.php


示例19: show_help

 private static function show_help($command)
 {
     $out = self::get_initial_markdown($command);
     $longdesc = $command->get_longdesc();
     if ($longdesc) {
         $out .= wordwrap($longdesc, 79) . "\n";
     }
     // section headers
     $out = preg_replace('/^## ([A-Z ]+)/m', Terminus::colorize('%9\\1%n'), $out);
     // definition lists
     $out = preg_replace_callback('/([^\\n]+)\\n: (.+?)(\\n\\n|$)/s', array(__CLASS__, 'rewrap_param_desc'), $out);
     $out = str_replace("\t", '  ', $out);
     self::pass_through_pager($out);
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:14,代码来源:help.php


示例20: send

 public static function send($url, $method, $data = array())
 {
     // create a new Guzzle\Http\Client
     $browser = new Browser();
     $browser->setUserAgent(self::userAgent());
     $options = array();
     $options['allow_redirects'] = @$data['allow_redirects'] ?: false;
     $options['json'] = @$data['json'] ?: false;
     if (@$data['body']) {
         $options['body'] = $data['body'];
         if (\Terminus::get_config("debug")) {
             \Terminus\Loggers\Regular::debug($data['body']);
         }
     }
     $options['verify'] = false;
     $request = $browser->createRequest($method, $url, null, null, $options);
     if (!empty($data['postdata'])) {
         foreach ($data['postdata'] as $k => $v) {
             $request->setPostField($k, $v);
         }
     }
     if (!empty($data['cookies'])) {
         foreach ($data['cookies'] as $k => $v) {
             $request->addCookie($k, $v);
         }
     }
     if (!empty($data['headers'])) {
         foreach ($data['headers'] as $k => $v) {
             $request->setHeader($k, $v);
         }
     }
     if (\Terminus::get_config("debug")) {
         $debug = "#### REQUEST ####" . PHP_EOL;
         $debug .= $request->getRawHeaders();
         \Terminus\Loggers\Regular::debug($debug);
         if (isset($data['body'])) {
             \Terminus\Loggers\Regular::debug($data['body']);
         }
     }
     if (getenv("BUILD_FIXTURES")) {
         Fixtures::put("request_headers", $request->getRawHeaders());
     }
     $response = $request->send();
     if (getenv("BUILD_FIXTURES")) {
         Fixtures::put(array($url, $method, $data), $response);
     }
     return $response;
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:48,代码来源:Request.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Test类代码示例发布时间:2022-05-23
下一篇:
PHP Term类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap