PHP code example of getkirby / cli

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

    

getkirby / cli example snippets




return [
    'description' => 'Nice command',
    'args' => [],
    'command' => static function ($cli): void {
        $cli->success('Nice command!');
    }
];

Kirby::plugin('your/plugin', [
  'commands' => [
    'your-plugin:test' => [
      'description' => 'Nice command',
      'args' => [],
      'command' => function ($cli) {
        $cli->success('My first plugin command');
      }
    ]
  ]
]);

$cli->out('This is some simple text');

$cli->success('This is text in a nice green box');

$cli->error('This is red text for errors');

$cli->bold('This is some bold text');

// this will create a line break
$cli->br();



return [
    'description' => 'Hello world',
    'args' => [
        'name' => [
            'description' => 'The name for the greeting',
            '



return [
    'description' => 'Hello world',
    'command' => static function ($cli): void {
        $name = $cli->prompt('Please enter a name:');
        $cli->success('Hello ' . $name . '!');
    }
];



return [
    'description' => 'Hello world',
    'args' => [
        'name' => [
            'description' => 'The name for the greeting',
        ]
    ],
    'command' => static function ($cli): void {
        $name = $cli->argOrPrompt('name', 'Please enter a name:');
        $cli->success('Hello ' . $name . '!');
    }
];



return [
    'description' => 'Downloads the starterkit and the plainkit',
    'command' => static function ($cli): void {

        $cli->command('install:kit', 'starterkit');
        $cli->command('install:kit', 'plainkit');

        $cli->success('Starterkit and plainkit have been installed');
    }
];

composer global