Skip to content

Commit 4f5dbb5

Browse files
author
user52
committed
edits made
1 parent a8016d3 commit 4f5dbb5

File tree

14 files changed

+411
-29
lines changed

14 files changed

+411
-29
lines changed

.idea/console.iml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 302 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
use Symfony\Component\Console\Input\InputOption;
77
use Symfony\Component\Console\Output\OutputInterface;
88

9-
class GreetCommand extends Command
9+
class CreateController extends Command
1010
{
11-
protected $commandName = 'app:class';
11+
protected $commandName = 'app:controller';
1212
protected $commandDescription = "Greets Someone";
1313

1414
protected $commandArgumentName = "name";
@@ -40,19 +40,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
4040
{
4141
$name = $input->getArgument($this->commandArgumentName);
4242

43-
if ($name) {
44-
$text = 'Create Commands/'.$name;
43+
$content = file_get_contents("Commands/files/Controller.php");
44+
$content = str_replace("class Controller", "class $name", $content);
45+
46+
$file = fopen("app/controllers/$name.php", "w+");
47+
$result = fwrite($file, $content);
48+
fclose($file);
49+
50+
if ($result) {
51+
$text = "Created $name";
4552
} else {
46-
$text = 'Hello';
53+
$text = "Error";
4754
}
4855

4956
if ($input->getOption($this->commandOptionName)) {
5057
$text = strtoupper($text);
5158
}
52-
53-
$file = fopen("Commands/$name.php", "w+");
54-
fwrite($file, file_get_contents("greet.php"));
55-
fclose($file);
5659

5760
$output->writeln($text);
5861
}

0 commit comments

Comments
 (0)