PHP code example of wilkques / console

1. Go to this page and download the library: Download wilkques/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/ */

    

wilkques / console example snippets


    

    namespace App\Console;

    use Wilkques\Console\Command;

    class DoSomethingCommand extends Command
    {
        /**
         * signature
         *
         * @var string
         */
        public $signature = "do:something
                            {--debug : debug mode}
                            {--list : get list}";

        /**
         * description
         *
         * @var string
         */
        public $description = "do something";

        /**
         * handle this command
         *
         * @return int|null  null (or no return) means success; any int is the
         *                   process exit code
         */
        public function handle()
        {
            // do something
        }
    }
    

      $command = $argv;

    array_shift($command);

    // handle() returns the exit code — pass it to exit() so a failing
    // command is visible to CI, cron and shell scripts.
    exit(
        console()
        ->setCommandRootPath("<set console dir path>") // if you want change path
        ->setComposerPath("<composer.json path>") // if you want change
        ->boot()
        ->handle($command)
    );
    

public $signature = 'member:get {username : the username to look up}';

public function handle()
{
    $username = $this->argument('username');
}

public $signature = 'deploy
    {environment : which environment to deploy}
    {branch? : branch to deploy, defaults to the current one}
    {--tag=latest : image tag}
    {servers* : one or more servers to deploy to}';

php artisan deploy production main web-1 web-2
// $this->argument('environment') === 'production'
// $this->argument('branch')      === 'main'
// $this->argument('servers')     === ['web-1', 'web-2']