我很好奇,我正在用拉威尔和Artisan进行migrations.是否有向控制台输出信息的方法?我似乎找不到这方面的任何信息.例如:

<?php

class Generate_Sample_Users{

    public function up(){

        //Echo to console here
        echo "Creating sample users...";

        $generator = new Sample_Data();
        $user_count = 30;
        $users = array();


        for($i=0; $i < $user_count; $i++){
            array_push($users, $generator->generate_user($i));
        }

        DB::table('users')->insert($users);
    }

    public function down(){
        DB::table('users')->delete();
    }

}

推荐答案

Don't know if you are using Laravel 3 or Laravel 4, and if its also possible in Laravel 3, but i found this in the docs.

$this->info('Creating sample users...');

EDIT

如果切换到database seeds,则可以使用该选项显示消息

$this->command->info('Creating sample users...');

Laravel相关问答推荐

Laravel Livewire与自定义JS有关的多姆问题

使用 laravel 根据当月显示注册用户列表

如何将用户对象绑定到中间件中的请求

所有 POST 请求上的 Laravel 4 CSRF

laravel 控制器中的全局变量

查询 Laravel Select WhereIn 数组

如何在 laravel 中使用 str_replace

查询构建器中的 Laravel 5 多重 Select ()

在表单中添加一对多 - Backpack laravel

laravel 5 - assets资源 list 中未定义 css 文件?

Laravel - 批量分配异常错误

如何在 Laravel 5 中验证当前、新密码和新密码确认?

Laravel 初学者的良好开端

Eloquent - 更新集合中的所有模型

如何在 Laravel 4 中使用 SHA1 加密而不是 BCrypt?

为什么在 Laravel 的 DB::select 中使用 DB::raw?

命令未定义异常

未找到列:1054 未知列 laravel

Laravel 获取查询字符串

phpunit 命令不适用于 Windows 7 上的 laravel 4