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


PHP Cli::error方法代码示例

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


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

示例1: render_cli_error

 private function render_cli_error($heading, array $messages, $traces = [])
 {
     $cli = new Cli();
     $cli->error(sprintf('<underline><bold>%s</bold></underline>', $heading));
     foreach ($messages as $label => $message) {
         $cli->error(sprintf('%s : <bold>%s</bold>', $label, $message));
     }
     if ($traces) {
         $cli->br()->error('<underline><bold>Backtrace</bold></underline>');
         $i = 1;
         foreach ($traces as $error) {
             $line = isset($error['line']) ? $error['line'] : 'Unknown';
             if (isset($error['file'])) {
                 $console->out(' ' . $i . ') ' . str_replace(FCPATH, './', $error['file']) . ':' . $line);
             } else {
                 $i--;
             }
             $func = '';
             if (isset($error['class'], $error['type'])) {
                 $func .= $error['class'] . $error['type'];
             }
             $func .= $error['function'];
             $console->error('    ' . $func . '()');
             $i++;
         }
     }
 }
开发者ID:projek-xyz,项目名称:ci-console,代码行数:27,代码来源:ExceptionsTrait.php

示例2: install

 /**
  * Runs the CMF installer
  */
 public function install()
 {
     if (strtolower(\Cli::prompt('Install CMF now? WARNING: This will reset the contents of your app folder!', array('y', 'n'))) !== 'y') {
         return;
     }
     // Site title etc
     Installer::initialSetup();
     // Database
     if (strtolower(\Cli::prompt('Create database now?', array('y', 'n'))) === 'y') {
         $result = Installer::createDatabase();
         if (isset($result['error'])) {
             \Cli::error('There was an error creating the database: ' . $result['error']);
             exit;
         }
     }
     // This stuff relies on the database being set up
     if (Project::databaseExists()) {
         // Sync models
         \Cli::write("");
         // Just a spacer!
         Project::sync('default', 'app', true, true);
         // Super user
         $hasSuper = Project::hasSuperUser();
         if (!$hasSuper || strtolower(\Cli::prompt('Create super user now?', array('y', 'n'))) === 'y') {
             if (!$hasSuper) {
                 \Cli::write("\nCreating a super user...");
             }
             Project::createSuperUser();
         }
         // Check some DB settings are in place
         Project::ensureMinimumSettings();
     }
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:36,代码来源:cmf.php

示例3: monitor

 public function monitor($file, $channel)
 {
     if (false === ($fp = @fopen($file, "r"))) {
         Cli::error("Failed to open {$file}");
     } else {
         Cli::out("Monitoring file: {$file}");
     }
     while (1) {
         if (-1 === fseek($fp, 0, SEEK_END) or !($pos = ftell($fp))) {
             goto retry;
         }
         if ($this->lastPosition === null or $this->lastPosition > $pos) {
             $this->lastPosition = $pos;
             goto retry;
         }
         if ($this->lastPosition < $pos) {
             fseek($fp, $this->lastPosition - $pos, SEEK_CUR);
             if (false === ($content = fread($fp, $pos - $this->lastPosition))) {
                 goto retry;
             }
             try {
                 $this->client->send($content, $channel);
             } catch (\Exception $ex) {
                 Cli::error($ex->getMessage());
             }
             $this->lastPosition = $pos;
         }
         retry:
         usleep(200000);
     }
 }
开发者ID:joy2fun,项目名称:websocket-console-client,代码行数:31,代码来源:FileClient.php

示例4: foursquare_venue

 public function foursquare_venue($venue_id, $cycles = 25)
 {
     if ($this->spider->updateFoursquareVenue($venue_id, $cycles)) {
         \Cli::write('Scan finished.');
     } else {
         \Cli::error('No region found / Invalid region id');
     }
 }
开发者ID:neostoic,项目名称:healthyfood,代码行数:8,代码来源:instagram_pictures.php

示例5: main

 private function main()
 {
     \Cli::write(sprintf('Fuel %s - PHP %s (%s) (%s) [%s]', \Fuel::VERSION, phpversion(), php_sapi_name(), self::build_date(), PHP_OS));
     // Loop until they break it
     while (TRUE) {
         if (\Cli::$readline_support) {
             readline_completion_function(array(__CLASS__, 'tab_complete'));
         }
         if (!($__line = rtrim(trim(trim(\Cli::input('>>> ')), PHP_EOL), ';'))) {
             continue;
         }
         if ($__line == 'quit') {
             break;
         }
         // Add this line to history
         //$this->history[] = array_slice($this->history, 0, -99) + array($line);
         if (\Cli::$readline_support) {
             readline_add_history($__line);
         }
         if (self::is_immediate($__line)) {
             $__line = "return ({$__line})";
         }
         ob_start();
         // Unset the previous line and execute the new one
         $random_ret = \Str::random();
         try {
             $ret = eval("unset(\$__line); {$__line};");
         } catch (\Exception $e) {
             $ret = $random_ret;
             $__line = $e->getMessage();
         }
         // Error was returned
         if ($ret === $random_ret) {
             \Cli::error('Parse Error - ' . $__line);
             \Cli::beep();
         }
         if (ob_get_length() == 0) {
             if (is_bool($ret)) {
                 echo $ret ? 'true' : 'false';
             } elseif (is_string($ret)) {
                 echo addcslashes($ret, "....ÿ");
             } elseif (!is_null($ret)) {
                 var_export($ret);
             }
         }
         unset($ret);
         $out = ob_get_contents();
         ob_end_clean();
         if (strlen($out) > 0 && substr($out, -1) != PHP_EOL) {
             $out .= PHP_EOL;
         }
         echo $out;
         unset($out);
     }
 }
开发者ID:highestgoodlikewater,项目名称:webspider-1,代码行数:55,代码来源:console.php

示例6: add

 public function add($keyword)
 {
     if (!$keyword) {
         \Cli::error('Please provide keyword');
         return;
     }
     if (!\Collection\Keyword::addKeywordToDB($keyword)) {
         \Cli::error('Keyword already exists');
         return;
     }
     \Cli::write('Keyword added.');
 }
开发者ID:neostoic,项目名称:healthyfood,代码行数:12,代码来源:keywords.php

示例7: write

 /**
  * {@inheritdocs}
  */
 protected function write(array $record)
 {
     if (\Fuel::$is_cli) {
         $colors = \Arr::get($this->levels, $record['level'], array('white', null));
         list($fg, $bg) = $colors;
         $message = \Cli::color((string) $record['formatted'], $fg, $bg);
         if ($level >= 300) {
             \Cli::error($message);
         } else {
             \Cli::write($message);
         }
     }
 }
开发者ID:indigophp,项目名称:fuel-core,代码行数:16,代码来源:ConsoleHandler.php

示例8: getQueuedItems

 public static function getQueuedItems($source, $frequency = 'hourly', $limit = 100, $region_id = false)
 {
     $query = \DB::select()->from(self::$_table_name);
     $query->join('tracking_cycle');
     $query->on('tracking_cycle.object_id', '=', 'tracking_log.object_id');
     $query->join('singleton');
     $query->on('tracking_log.object_id', '=', 'singleton.id');
     $query->where('tracking_log.success', 1);
     $query->where('tracking_log.is_latest', 1);
     $query->where('tracking_cycle.frequency', $frequency);
     $query->where('tracking_log.source', $source);
     if ($region_id) {
         $query->join('venue');
         $query->on('venue.id', '=', 'singleton.id');
         $query->where('venue.region_id', $region_id);
     }
     switch ($frequency) {
         case 'quaterday':
             $query->where('tracking_log.created_at', '<=', \DB::expr('DATE_SUB(NOW(),INTERVAL 6 HOUR)'));
             break;
         case 'hourly':
             $query->where('tracking_log.created_at', '<=', \DB::expr('DATE_SUB(NOW(),INTERVAL 1 HOUR)'));
             break;
         case 'daily':
             $query->where('tracking_log.created_at', '<=', \DB::expr('DATE_SUB(NOW(),INTERVAL 1 DAY)'));
             break;
         case 'weekly':
             $query->where('tracking_log.created_at', '<=', \DB::expr('DATE_SUB(NOW(),INTERVAL 7 DAY)'));
             break;
         case 'monthly':
             $query->where('tracking_log.created_at', '<=', \DB::expr('DATE_SUB(NOW(),INTERVAL 1 MONTH)'));
             break;
         default:
             \Cli::error('Failure: Invalid frequency type');
             return;
     }
     if (0) {
         $query->join('venue_record');
         $query->on('venue_record.id', '=', 'singleton.id');
         $query->order_by('venue_record.checkin', 'desc');
     } else {
         $query->order_by('tracking_log.created_at', 'asc');
     }
     $query->limit($limit);
     $tracking_logs = $query->execute();
     // echo \DB::last_query();
     //  exit;
     return $tracking_logs;
 }
开发者ID:neostoic,项目名称:healthyfood,代码行数:49,代码来源:log.php

示例9: error

 public function error($errno, $error, $file, $line)
 {
     $msg = $error . "({$errno})" . $file . " ({$line}).";
     IS_CLI and Cli::error($msg);
     switch ($errno) {
         case E_NOTICE:
         case E_USER_NOTICE:
         case E_DEPRECATED:
             break;
         default:
             if (c('app.debug') === true) {
                 require __DIR__ . '/view/debug.php';
                 exit;
             } else {
                 class_exists('Log') && Log::write($msg, $this->errorType($errno));
                 die(view(c('view.bug')));
             }
     }
 }
开发者ID:houdunwang,项目名称:hdphp,代码行数:19,代码来源:Error.php

示例10: mysql

 public function mysql()
 {
     $db = \DbConfig::get_params();
     $dbname = $db['dbname'];
     $scheme_sql = 'CREATE DATABASE IF NOT EXISTS `' . $dbname . '`;';
     $scheme_sql .= 'DROP TABLE IF EXISTS `comment`;';
     $scheme_sql .= 'DROP TABLE IF EXISTS `post`;';
     $scheme_sql .= file_get_contents(APPPATH . '../../schema/php_dev.sql');
     foreach (explode(';', $scheme_sql) as $sql) {
         if (preg_match('/^\\n$/u', $sql)) {
             continue;
         }
         $result = \DB::query($sql)->execute();
         if ($result) {
             \Cli::write(\Cli::color($sql, 'green'));
         } else {
             \Cli::error(\Cli::color($sql, 'red'));
         }
     }
 }
开发者ID:pagmovel,项目名称:php-orm-benchmark,代码行数:20,代码来源:setup.php

示例11: updateVenuesService

 public function updateVenuesService()
 {
     while (1) {
         if ($this->spider->getCurrentRateLimit() == 0) {
             // wait for 15min if we hit the rate limit
             $message = 'Warning: Rate limit hit! Script will pause for 15mins.';
             \Cli::error($message);
             $this->spider->emailReport($message);
             \Cli::wait(1800);
         }
         $success = $this->spider->updateVenues();
         if (!$success) {
             $message = 'Warning: Probably hit the rate limit. Foursquare headers incorrect at the moment! Script will pause for 15mins.';
             \Cli::error($message);
             $this->spider->emailReport($message);
             \Cli::wait(1800);
         } else {
             \Cli::wait(5, true);
         }
     }
 }
开发者ID:neostoic,项目名称:healthyfood,代码行数:21,代码来源:foursquare_venues.php

示例12: run

 /**
  * Called by: php oil r movescaffoldtomodule
  * Moves scaffold files to module.
  */
 public function run($args = NULL)
 {
     /* We handle here options:
      *  * scaffold alias s: name of the scaffold to move
      *  * module alias m: module to move the scaffold into
      *  * force alias f: do we override existing files ?
      */
     $scaffold = \Cli::option('scaffold', \Cli::option('s'));
     $module = \Cli::option('module', \Cli::option('m'));
     static::$force = \Cli::option('force', \Cli::option('f', false));
     // Checking if the scaffold and module options are
     // defined
     if (is_null($scaffold) || is_null($module)) {
         \Cli::error('Some parameters are missing.');
         \Cli::error('Ex: php oil r moveScaffoldToModule' . ' -scaffold=category -module=blog');
         return;
     }
     $module_path = \Module::exists($module);
     // Is the module found ?
     if ($module_path == null) {
         \Cli::error('The specified module doesn\'t exists!');
         return;
     }
     // Now processing each scaffold file / folders
     foreach (static::$files_to_move as $item) {
         $path = str_replace('(:scaffold)', $scaffold, $item['path']);
         if (file_exists(APPPATH . $path)) {
             /*
              * As each file type must be processed
              * differently, a different method is called
              * depending on the type. For instance, if
              * the file type is controller, we will call
              * the process_controller method.
              */
             static::{'process_' . $item['type']}($path, $module, $module_path);
         }
     }
     // Processing migration as it is a special cases.
     static::process_migration($scaffold, $module, $module_path);
 }
开发者ID:vano00,项目名称:blog,代码行数:44,代码来源:movescaffoldtomodule.php

示例13: run

 public function run($fonts = null)
 {
     if (\Cli::option('help', \Cli::option('h', false)) or empty($fonts)) {
         empty($fonts) and \Cli::error(\Cli::color('No font given.', 'red'));
         return static::help();
     }
     $pdf = new \TCPDF();
     $type = \Cli::option('type', \Cli::option('t', ''));
     $enc = \Cli::option('enc', \Cli::option('e', ''));
     $flags = \Cli::option('flags', \Cli::option('f', 32));
     $outpath = \Cli::option('outpath', \Cli::option('o', K_PATH_FONTS));
     $platid = \Cli::option('platid', \Cli::option('p', 3));
     $encid = \Cli::option('encid', \Cli::option('n', 1));
     $addcbbox = \Cli::option('addcbbox', \Cli::option('b', false));
     $link = \Cli::option('link', \Cli::option('l', false));
     $path = \Cli::option('path', \Cli::option('p'));
     if (!is_null($path) and !\Str::ends_with($path, DS)) {
         $path .= DS;
     }
     $fonts = explode(',', $fonts);
     foreach ($fonts as $font) {
         if (strpos($font, DS) === false and !is_null($path)) {
             $font = $path . $font;
         }
         $fontfile = realpath($font);
         $fontname = \TCPDF_FONTS::addTTFfont($fontfile, $type, $enc, $flags, $outpath, $platid, $encid, $addcbbox, $link);
         if ($fontname == false) {
             $errors = true;
             \Cli::error(\Cli::color($font . ' cannot be added.', 'red'));
         } else {
             \Cli::write(\Cli::color($font . ' added.', 'green'));
         }
     }
     if (!empty($errors)) {
         \Cli::error(\Cli::color('Process finished with errors.', 'red'));
     } else {
         \Cli::write(\Cli::color('Process successfully finished.', 'green'));
     }
 }
开发者ID:indigophp,项目名称:fuel-pdf,代码行数:39,代码来源:tcpdf.php

示例14: checkEnvVars

function checkEnvVars()
{
    $ret_php = -1;
    $output_php = array();
    $ret_arc = -1;
    $output_arc = array();
    exec("php -v", $output_php, $ret_php);
    exec("arc help", $output_arc, $ret_arc);
    if ($ret_arc === 0 && $ret_php === 0) {
        return true;
    } else {
        if ($ret_arc) {
            Cli::error("Could not add Arcanist to the enviromnment");
            echo concatString($output_arc) . PHP_EOL;
        }
        if ($ret_php) {
            Cli::error("Could not add PHP to the environment");
            echo concatString($output_php) . PHP_EOL;
        }
        return false;
    }
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:22,代码来源:inc.php

示例15: up

 public function up()
 {
     //populate the system roles if they don't exist
     if (\DBUtil::table_exists('roles')) {
         if (\DB::count_records('roles') == 0) {
             $roles = array(\Access::ROLE_ADMIN => 'Admin', \Access::ROLE_DEVELOPER => 'Developer', \Access::ROLE_EDITOR => 'Editor', \Access::ROLE_PENDING => 'Pending', \Access::ROLE_STANDARD => 'Standard', \Access::ROLE_SILVER => 'Silver', \Access::ROLE_GOLD => 'Gold', \Access::ROLE_DUMMY => 'Dummy');
             foreach ($roles as $id => $role) {
                 \DB::insert('roles')->set(array('id' => $id, 'name' => strtolower($role), 'Description' => $role))->execute();
             }
             \Cli::write("\nPopulated roles.");
         }
     }
     //create default admin user if we have no users
     if (\DBUtil::table_exists('users')) {
         if (\DB::count_records('users') == 0) {
             //create the admin user
             $data = array('username' => \Cli::prompt("Please enter an admin username"), 'email' => \Cli::prompt("Please enter an admin email"), 'password' => \Cli::prompt("Please enter an admin password"));
             try {
                 $user = new \Warden\Model_User($data);
                 if (\Config::get('warden.confirmable.in_use') === true) {
                     $user->is_confirmed = true;
                 }
                 \Access::set_roles(array(\Access::ROLE_STANDARD, \Access::ROLE_ADMIN), $user);
                 //this will assign the roles and save the user
                 \Cli::write("\nCreated admin user.");
                 \Cli::write(\Cli::color("\nUsername : {$user->username}", 'blue'));
                 \Cli::write(\Cli::color("\nEmail    : {$user->email}", 'blue'));
             } catch (\Exception $e) {
                 \Cli::error("\n:( Failed to create admin user because: " . $e->getMessage());
             }
         }
     }
     //create the blog table if it doesnt exist
     if (!\DBUtil::table_exists('blogs')) {
         \DBUtil::create_table('blogs', array('id' => array('constraint' => 11, 'type' => 'int', 'unsigned' => true, 'auto_increment' => true), 'user_id' => array('constraint' => 11, 'type' => 'int', 'unsigned' => true), 'title' => array('constraint' => 255, 'type' => 'varchar'), 'post' => array('type' => 'text'), 'publish_flag' => array('constraint' => 11, 'type' => 'int', 'default' => 0, 'unsigned' => true), 'public_flag' => array('constraint' => 11, 'type' => 'int', 'default' => 0, 'unsigned' => true), 'created_at' => array('type' => 'timestamp', 'default' => \DB::expr('CURRENT_TIMESTAMP')), 'updated_at' => array('type' => 'timestamp')), array('id'), true, 'InnoDB');
         \DBUtil::create_index('blogs', 'user_id', 'user_id');
     }
 }
开发者ID:jkapelner,项目名称:chatroom-web-server,代码行数:38,代码来源:001_create_tables.php


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