classRepositoryMakeCommandextendsGeneratorCommand { /** * The name and signature of the console command. * * @var string */ protected$name = 'make:repository';
/** * The console command description. * * @var string */ protected$description = 'Create a new repository class';
/** * The type of class being generated. * * @var string */ protected$type = 'Repository';
/** * Get the stub file for the generator. * * @return string */ protectedfunctiongetStub() { return__DIR__.'/stubs/repository.stub'; }
/** * Get the default namespace for the class. * * @param string $rootNamespace * @return string */ protectedfunctiongetDefaultNamespace($rootNamespace) { return$rootNamespace.'\Repositories'; } }
2、创建命令类对应的模版文件
在 app\Console\Commands\stubs 下创建模版文件 .stub 文件是 make 命令生成的类文件的模版,用来定义要生成的类文件的通用部分