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


PHP Cli::write方法代码示例

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


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

示例1: init

 public static function init($args)
 {
     try {
         if (!isset($args[1])) {
             static::help();
             return;
         }
         switch ($args[1]) {
             case 'g':
             case 'generate':
                 switch ($args[2]) {
                     case 'controller':
                     case 'model':
                     case 'view':
                     case 'views':
                     case 'migration':
                         call_user_func('Oil\\Generate::' . $args[2], array_slice($args, 3));
                         break;
                     case 'scaffold':
                         call_user_func('Oil\\Scaffold::generate', array_slice($args, 3));
                         break;
                     default:
                         Generate::help();
                 }
                 break;
             case 'c':
             case 'console':
                 new Console();
             case 'r':
             case 'refine':
                 $task = isset($args[2]) ? $args[2] : null;
                 call_user_func('Oil\\Refine::run', $task, array_slice($args, 3));
                 break;
             case 'p':
             case 'package':
                 switch ($args[2]) {
                     case 'install':
                     case 'uninstall':
                         call_user_func_array('Oil\\Package::' . $args[2], array_slice($args, 3));
                         break;
                     default:
                         Package::help();
                 }
                 break;
             case '-v':
             case '--version':
                 \Cli::write('Fuel: ' . \Fuel::VERSION);
                 break;
             case 'test':
                 \Fuel::add_package('octane');
                 call_user_func('\\Fuel\\Octane\\Tests::run_' . $args[2], array_slice($args, 3));
                 break;
             default:
                 static::help();
         }
     } catch (Exception $e) {
         \Cli::write(\Cli::color('Error: ' . $e->getMessage(), 'light_red'));
         \Cli::beep();
     }
 }
开发者ID:netspencer,项目名称:fuel,代码行数:60,代码来源:cli.php

示例2: run

 public static function run($task, $args)
 {
     // Make sure something is set
     if ($task === null or $task === 'help') {
         static::help();
         return;
     }
     // Just call and run() or did they have a specific method in mind?
     list($task, $method) = array_pad(explode(':', $task), 2, 'run');
     $task = ucfirst(strtolower($task));
     // Find the task
     if (!($file = \Fuel::find_file('tasks', $task))) {
         throw new Exception(sprintf('Task "%s" does not exist.', $task));
         return;
     }
     require $file;
     $task = '\\Fuel\\Tasks\\' . $task;
     $new_task = new $task();
     // The help option hs been called, so call help instead
     if (\Cli::option('help') && is_callable(array($new_task, 'help'))) {
         $method = 'help';
     }
     if ($return = call_user_func_array(array($new_task, $method), $args)) {
         \Cli::write($return);
     }
 }
开发者ID:netspencer,项目名称:fuel,代码行数:26,代码来源:refine.php

示例3: show_php_error

 public static function show_php_error(\Exception $e)
 {
     $data['type'] = get_class($e);
     $data['severity'] = $e->getCode();
     $data['message'] = $e->getMessage();
     $data['filepath'] = $e->getFile();
     $data['error_line'] = $e->getLine();
     $data['backtrace'] = $e->getTrace();
     $data['severity'] = !isset(static::$levels[$data['severity']]) ? $data['severity'] : static::$levels[$data['severity']];
     if (\Fuel::$is_cli) {
         \Cli::write(\Cli::color($data['severity'] . ' - ' . $data['message'] . ' in ' . \Fuel::clean_path($data['filepath']) . ' on line ' . $data['error_line'], 'red'));
         return;
     }
     $debug_lines = array();
     foreach ($data['backtrace'] as $key => $trace) {
         if (!isset($trace['file'])) {
             unset($data['backtrace'][$key]);
         } elseif ($trace['file'] == COREPATH . 'classes/error.php') {
             unset($data['backtrace'][$key]);
         }
     }
     $debug_lines = array('file' => $data['filepath'], 'line' => $data['error_line']);
     $data['severity'] = !isset(static::$levels[$data['severity']]) ? $data['severity'] : static::$levels[$data['severity']];
     $data['debug_lines'] = \Debug::file_lines($debug_lines['file'], $debug_lines['line']);
     $data['filepath'] = \Fuel::clean_path($debug_lines['file']);
     $data['filepath'] = str_replace("\\", "/", $data['filepath']);
     $data['error_line'] = $debug_lines['line'];
     echo \View::factory('errors' . DS . 'php_error', $data);
 }
开发者ID:netspencer,项目名称:fuel,代码行数:29,代码来源:error.php

示例4: run

	public static function run($task, $args)
	{
		// Just call and run() or did they have a specific method in mind?
		list($task, $method)=array_pad(explode(':', $task), 2, 'run');

		$task = ucfirst(strtolower($task));

		if ( ! $file = \Fuel::find_file('tasks', $task))
		{
			throw new \Exception('Well that didnt work...');
			return;
		}

		require $file;

		$task = '\\Fuel\\Tasks\\'.$task;

		$new_task = new $task;

		// The help option hs been called, so call help instead
		if (\Cli::option('help') && is_callable(array($new_task, 'help')))
		{
			$method = 'help';
		}

		if ($return = call_user_func_array(array($new_task, $method), $args))
		{
			\Cli::write($return);
		}
	}
开发者ID:nasumi,项目名称:fuel,代码行数:30,代码来源:refine.php

示例5: receive_sqs_for_multi

 public static function receive_sqs_for_multi()
 {
     $t1 = microtime(true);
     $pcount = 3;
     $pstack = array();
     for ($i = 1; $i <= $pcount; $i++) {
         $pid = pcntl_fork();
         if ($pid == -1) {
             die('fork できません');
         } else {
             if ($pid) {
                 // 親プロセスの場合
                 $pstack[$pid] = true;
                 if (count($pstack) >= $pcount) {
                     unset($pstack[pcntl_waitpid(-1, $status, WUNTRACED)]);
                 }
             } else {
                 sleep(1);
                 self::receive_sqs_message();
                 exit;
                 //処理が終わったらexitする。
             }
         }
     }
     //先に処理が進んでしまうので待つ
     while (count($pstack) > 0) {
         unset($pstack[pcntl_waitpid(-1, $status, WUNTRACED)]);
     }
     $t2 = microtime(true);
     $process_time = $t2 - $t1;
     \Cli::write("Process time = " . $process_time);
 }
开发者ID:inoue2302,项目名称:phplib,代码行数:32,代码来源:sqs.php

示例6: create

 /**
  * create the sessions table
  * php oil r session:create
  */
 public static function create()
 {
     // load session config
     \Config::load('session', true);
     if (\Config::get('session.driver') != 'db') {
         // prompt the user to confirm they want to remove the table.
         $continue = \Cli::prompt(\Cli::color('Your current driver type is not set db. Would you like to continue and add the sessions table anyway?', 'yellow'), array('y', 'n'));
         if ($continue === 'n') {
             return \Cli::color('Database sessions table was not created.', 'red');
         }
     }
     if (\DBUtil::table_exists(\Config::get('session.db.table'))) {
         return \Cli::write('Session table already exists.');
     }
     // create the session table using the table name from the config file
     \DBUtil::create_table(\Config::get('session.db.table'), array('session_id' => array('constraint' => 40, 'type' => 'varchar'), 'previous_id' => array('constraint' => 40, 'type' => 'varchar'), 'user_agent' => array('type' => 'text', 'null' => false), 'ip_hash' => array('constraint' => 32, 'type' => 'char'), 'created' => array('constraint' => 10, 'type' => 'int', 'unsigned' => true), 'updated' => array('constraint' => 10, 'type' => 'int', 'unsigned' => true), 'payload' => array('type' => 'longtext')), array('session_id'), false, 'InnoDB', \Config::get('db.default.charset'));
     // make previous_id a unique_key. speeds up query and prevents duplicate id's
     \DBUtil::create_index(\Config::get('session.db.table'), 'previous_id', 'previous_id', 'unique');
     if (\Config::get('session.driver') === 'db') {
         // return success message.
         return \Cli::color('Success! Your session table has been created!', 'green');
     } else {
         // return success message notifying that the driver is not db.
         return \Cli::color('Success! Your session table has been created! Your current session driver type is set to ' . \Config::get('session.driver') . '. In order to use the table you just created to manage your sessions, you will need to set your driver type to "db" in your session config file.', 'green');
     }
 }
开发者ID:vienbk91,项目名称:fuelphp17,代码行数:30,代码来源:session.php

示例7: run

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

示例8: 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

示例9: sync

 /**
  * Sync assets to CDN
  */
 public function sync()
 {
     \Cli::write("Syncing user files...");
     Storage::syncFileFields();
     \Cli::write("Syncing static assets...");
     Storage::syncAssets();
     \Cli::write("Done!", 'green');
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:11,代码来源:assets.php

示例10: set_reservable

 /**
  *
  * @return string
  */
 public function set_reservable()
 {
     \Config::load("base");
     $taskName = __METHOD__;
     \Cli::write(\TaskUtil::decorate(\Config::get("system.code") . " {$taskName} START"));
     $model = new \Model_Task_Setreservable();
     $model->run();
     \Cli::write(\TaskUtil::decorate(\Config::get("system.code") . " {$taskName} END"));
 }
开发者ID:marietta-adachi,项目名称:website,代码行数:13,代码来源:daily.php

示例11: down

 public static function down()
 {
     \Config::load('migrate', true);
     $version = \Config::get('migrate.version') - 1;
     if (\Migrate::version($version)) {
         static::_update_version($version);
         \Cli::write('Migrated to version: ' . $version . '.', 'green');
     }
 }
开发者ID:huglester,项目名称:fuel-uploadify,代码行数:9,代码来源:migrate.php

示例12: run

 /**
  *
  * @return string
  */
 public function run($type)
 {
     \Config::load("base");
     $taskName = "DATA MIGRATION";
     \Cli::write(\TaskUtil::decorate(\Config::get("system.code") . " {$taskName} START"));
     $model = new \Model_Task_Datamigration();
     $model->run($type);
     \Cli::write(\TaskUtil::decorate(\Config::get("system.code") . " {$taskName} END"));
 }
开发者ID:marietta-adachi,项目名称:website,代码行数:13,代码来源:datamigration.php

示例13: 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

示例14: customer

 /**
  * Processes customer statistics.
  *
  * @return void
  */
 public static function customer()
 {
     if (!($task = \Service_Statistic_Task::begin('customer'))) {
         return false;
     }
     $data = array();
     $date_ranges = \Service_Statistic_Task::date_ranges('customer');
     foreach ($date_ranges as $range) {
         $begin = \Date::create_from_string($range['begin'], 'mysql');
         $end = \Date::create_from_string($range['end'], 'mysql');
         $date = $begin->format('mysql_date');
         $data[$date] = array();
         $created = \Service_Customer_Statistic::created($begin, $end);
         foreach ($created as $result) {
             $data[$date][] = array('seller_id' => $result['seller_id'], 'name' => 'created', 'value' => $result['total']);
         }
         $deleted = \Service_Customer_Statistic::deleted($begin, $end);
         foreach ($deleted as $result) {
             $data[$date][] = array('seller_id' => $result['seller_id'], 'name' => 'deleted', 'value' => $result['total']);
         }
         $subscribed = \Service_Customer_Statistic::subscribed($begin, $end);
         foreach ($subscribed as $result) {
             $data[$date][] = array('seller_id' => $result['seller_id'], 'name' => 'subscribed', 'value' => $result['total']);
         }
         $unsubscribed = \Service_Customer_Statistic::unsubscribed($begin, $end);
         foreach ($unsubscribed as $result) {
             $data[$date][] = array('seller_id' => $result['seller_id'], 'name' => 'unsubscribed', 'value' => $result['total']);
         }
         $total = \Service_Customer_Statistic::total($end);
         foreach ($total as $result) {
             $data[$date][] = array('seller_id' => $result['seller_id'], 'name' => 'total', 'value' => $result['total']);
         }
         $total_active = \Service_Customer_Statistic::total_active($end);
         foreach ($total_active as $result) {
             $data[$date][] = array('seller_id' => $result['seller_id'], 'name' => 'total_active', 'value' => $result['total']);
         }
         $total_subscribed = \Service_Customer_Statistic::total_subscribed($end);
         foreach ($total_subscribed as $result) {
             $data[$date][] = array('seller_id' => $result['seller_id'], 'name' => 'total_subscribed', 'value' => $result['total']);
         }
     }
     // Save the queried results as statistics.
     foreach ($data as $date => $results) {
         $date = \Date::create_from_string($date, 'mysql_date');
         foreach ($results as $result) {
             $seller = \Service_Seller::find_one($result['seller_id']);
             if (!\Service_Statistic::create($seller, 'customer', $date, $result['name'], $result['value'])) {
                 \Service_Statistic_Task::end($task, 'failed', "Error creating customer.{$result['name']} statistic for seller {$seller->name}.");
                 return;
             }
         }
     }
     \Service_Statistic_Task::end($task);
     \Cli::write('Customer Statistical Calculations Complete', 'green');
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:60,代码来源:statistics.php

示例15: run

 public static function run()
 {
     $writable_paths = array(APPPATH . 'cache', APPPATH . 'logs', APPPATH . 'tmp', APPPATH . 'config');
     foreach ($writable_paths as $path) {
         if (@chmod($path, 0777)) {
             \Cli::write("\t" . 'Made writable: ' . $path, 'green');
         } else {
             \Cli::write("\t" . 'Failed to make writable: ' . $path, 'red');
         }
     }
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:11,代码来源:install.php


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