51 ->setName(
'make:component')
52 ->setDescription(
'Create a simple component with a class and a template')
53 ->addArgument(
'name', InputArgument::REQUIRED,
'component name')
54 ->addOption(
'module',
null, InputOption::VALUE_REQUIRED,
'module id')
55 ->addOption(
'no-module',
null, InputOption::VALUE_NONE,
'component will be created in components folder, outside the module')
56 ->addOption(
'local',
null, InputOption::VALUE_NONE,
'component will be created in DOCUMENT_ROOT/local folder')
57 ->addOption(
'root',
null, InputOption::VALUE_REQUIRED,
'the root folder for generate. Defaults server document root')
58 ->addOption(
'show',
null, InputOption::VALUE_NONE,
'outputs to console, without saving it')
62 protected function execute(InputInterface $input, OutputInterface
$output): int
68 namespace: $namespace,
69 module: $input->getOption(
'module') ?? explode(
'.',
$name)[0],
70 noModule: $input->getOption(
'no-module') ===
true,
71 local: $input->getOption(
'local') ===
true,
72 root: $input->getOption(
'root'),
75 $styledOutput =
new SymfonyStyle($input,
$output);
77 $pathToComponent = $this->service->getPathToComponent($dto);
79 if ($input->getOption(
'show') ===
true)
81 $styledOutput->title(
'===============CLASS===============');
82 $styledOutput->text($this->service->generateClassContent($dto));
83 $styledOutput->title(
'==============TEMPLATE=============');
84 $styledOutput->text($this->service->generateTemplateContent($dto));
85 $styledOutput->title(
'=============LANG FILE=============');
86 $styledOutput->text($this->service->generateLangContent($dto));
87 $styledOutput->title(
' ');
88 $styledOutput->success(
"The component '$name' will be created using the path $pathToComponent\n");
92 $this->service->generateClassFile($dto);
93 $this->service->generateTemplateFile($dto);
94 $this->service->generateLangFile($dto);
95 $styledOutput->success(
"The component '$name' was created using the path $pathToComponent\n");
98 $styledOutput->title(
"===============USAGE===============");
99 $styledOutput->writeln(<<<PHP
101 '{$namespace}:{$name}',
108 return self::SUCCESS;