yii\helpers\BaseConsole::output PHP Method

output() public static method

Prints text to STDOUT appended with a carriage return (PHP_EOL).
public static output ( string $string = null ) : integer | boolean
$string string the text to print
return integer | boolean number of bytes printed or false on error.
    public static function output($string = null)
    {
        return static::stdout($string . PHP_EOL);
    }

Usage Example

 public function up()
 {
     $user = new User();
     $password_hash = Yii::$app->security->generatePasswordHash('123456');
     $auth_key = Yii::$app->security->generateRandomString();
     $time = time();
     $user->setAttributesAll = [['username' => 'caicai1', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time], ['username' => 'caicai2', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time], ['username' => 'caicai3', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time], ['username' => 'caicai4', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time], ['username' => 'caicai5', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time], ['username' => 'caicai6', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time], ['username' => 'caicai7', 'avatar' => '', 'password_hash' => $password_hash, 'auth_key' => $auth_key, 'password_reset_token' => '', 'email' => '*****@*****.**', 'created_at' => $time, 'updated_at' => $time]];
     $ret = $user->saveAll();
     if ($ret !== true) {
         BaseConsole::output("测试数据初始化出错," . $ret . '(请手动初始化)');
     }
 }