我正在尝试使用自定义artisan make命令生成类文件。我的命令显示在artisan make下,但我无法生成文件我做了什么
1。使用php artisan make:command CreateActionClass and implement GeneratorCommand
<?php
namespace App\Console\Commands;
use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Input\InputArgument;
class CreateActionClass extends GeneratorCommand
{
protected $signature = 'make:action {name}';
protected $description = 'Create New Action Single Responsibility';
protected $type = 'Action';
public function handle()
{
//
}
protected function getStub()
{
return app_path().'/Console/Stubs/MakeActionStub.stub';
}
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace.'\Actions';
}
protected function getArguments()
{
return [
['name', InputArgument::REQUIRED, 'The name of the contract.'],
];
}}
2。生成.stub文件/Console/Stubs/MakeActionStub.stub
<?php
namespace DummyNamespace;
class DummyAction
{
}
请帮助
handle
方法。它覆盖了GeneratorCommand
类的handle
,因此它什么也不做。如果您想扩展handle
方法,请在语句之前或之后调用parent::handle()