Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-09-30 17:41:28 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-09-30 17:41:28 +0400
commit7b7b0c043f4353ccbe076024b7df7e9669f0a158 (patch)
tree286fecb646db431b1aafe140a3d91532d2493f8e /plugins/ExampleCommand
parent9189856b90d8285dc61d83f356f2c046571bda45 (diff)
I noticed the example command was lacking a bit of documentation / help on how to continue after generating this command
Diffstat (limited to 'plugins/ExampleCommand')
-rw-r--r--plugins/ExampleCommand/Commands/HelloWorld.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/plugins/ExampleCommand/Commands/HelloWorld.php b/plugins/ExampleCommand/Commands/HelloWorld.php
index 5c0d415dcd..cdaee9f290 100644
--- a/plugins/ExampleCommand/Commands/HelloWorld.php
+++ b/plugins/ExampleCommand/Commands/HelloWorld.php
@@ -15,9 +15,19 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
+ * This class lets you define a new command. To read more about commands have a look at our Piwik Console guide on
+ * http://developer.piwik.org/guides/piwik-on-the-command-line
+ *
+ * As Piwik Console is based on the Symfony Console you might also want to have a look at
+ * http://symfony.com/doc/current/components/console/index.html
*/
class HelloWorld extends ConsoleCommand
{
+
+ /**
+ * This methods allows you to configure your command. Here you can define the name and description of your command
+ * as well as all options and arguments you expect when executing it.
+ */
protected function configure()
{
$this->setName('examplecommand:helloworld');
@@ -26,7 +36,15 @@ class HelloWorld extends ConsoleCommand
}
/**
- * Execute command like: ./console examplecommand:helloworld --name="The Piwik Team"
+ * The actual task is defined in this method. Here you can access any option or argument that was defined on the
+ * command line via $input and write anything to the console via $output argument.
+ * In case anything went wrong during the execution you should throw an exception to make sure the user will get a
+ * useful error message and to make sure the command does not exit with the status code 0.
+ *
+ * Ideally, the actual command is quite short as it acts like a controller. It should only receive the input values,
+ * execute the task by calling a method of another class and output any useful information.
+ *
+ * Execute the command like: ./console examplecommand:helloworld --name="The Piwik Team"
*/
protected function execute(InputInterface $input, OutputInterface $output)
{