PHP code example of uniondrug / console

1. Go to this page and download the library: Download uniondrug/console library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

uniondrug / console example snippets


$ php console
   __  __      _             ____                  
  / / / /___  (_)___  ____  / __ \_______  ______ _
 / / / / __ \/ / __ \/ __ \/ / / / ___/ / / / __ `/
/ /_/ / / / / / /_/ / / / / /_/ / /  / /_/ / /_/ / 
\____/_/ /_/_/\____/_/ /_/_____/_/   \__,_/\__, /  
                                          /____/   Console 1.0.0

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -e, --env[=ENV]       The environment the command should run under. [default: "development"]
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  config      列出所有配置文件
  help        Displays help for a command
  list        Lists commands


$ php console config -e production
+-----------------------------------+----------------------+
| Key                               | Value                |
+-----------------------------------+----------------------+
| key.k1.k2                         | value                |
+-----------------------------------+----------------------+

namespace App\Commands;

use Uniondrug\Console\Command;

class LocalCommand extends Command
{
    public function configure()
    {
        $this->setName('local:name');
    }

    public function handle()
    {
        $this->line("Hello world");
    }
}