PHP code example of buzzingpixel / corbomite-cli

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

    

buzzingpixel / corbomite-cli example snippets



declare(strict_types=1);

use corbomite\di\Di;
use corbomite\cli\Kernel as CliKernel;

define('APP_BASE_PATH', __DIR__);
define('APP_VENDOR_PATH', APP_BASE_PATH . '/vendor');



declare(strict_types=1);

return [
    'group-name' => [
        'description' => 'Very short description of group',
        'commands' => [
            'my-command' => [
                'description' => 'Very short description of command',
                'class' => \some\action\ClassName::class,
                'method' => 'myMethod', // defaults to __invoke()
            ],
            'another-command' => [
                'description' => 'Very short description of command',
                'class' => \some\action\ClassName::class,
            ],
        ],
    ],
    'another-name' => [
        'description' => 'Very short description of group',
        'commands' => [
            'my-command' => [
                'description' => 'Very short description of command',
                'class' => \some\action\ClassName::class,
            ],
        ],
    ],
];


declare(strict_types=1);

namespace my\name\space;

use corbomite\cli\models\CliArgumentsModel;
use corbomite\cli\services\CliQuestionService;

class CreateMigrationAction
{
    private $cliQuestionService;

    public function __construct(
        CliQuestionService $cliQuestionService
    ) {
        $this->cliQuestionService = $cliQuestionService;
    }

    public function __invoke(CliArgumentsModel $argModel)
    {
        // Optionally check for argument on the command line before asking
        if (! $val = $argModel->getArgumentByIndex(2)) {
            $val = $this->cliQuestionService->ask(
                '<fg=cyan>Ask some question: </>'
            );
        }

        // ...do something with $val
    }
}