feat: Generate class command (#6158)

This commit is contained in:
Leo Cavalcante 2023-09-18 22:54:28 -03:00 committed by GitHub
parent 28c74a1b96
commit 618424564b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 0 deletions

View File

@ -29,6 +29,9 @@ return [
'aspect' => [
'namespace' => 'App\\Aspect',
],
'class' => [
'namespace' => 'App',
],
'command' => [
'namespace' => 'App\\Command',
],

View File

@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Hyperf\Devtool\Generator;
use Hyperf\Command\Annotation\Command;
#[Command]
class ClassCommand extends GeneratorCommand
{
public function __construct()
{
parent::__construct('gen:class');
}
public function configure()
{
$this->setDescription('Create a new class');
parent::configure();
}
protected function getStub(): string
{
return $this->getConfig()['stub'] ?? __DIR__ . '/stubs/class.stub';
}
protected function getDefaultNamespace(): string
{
return $this->getConfig()['namespace'] ?? 'App';
}
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace %NAMESPACE%;
class %CLASS%
{
}