PHP code example of citomni / cli

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

    

citomni / cli example snippets



declare(strict_types=1);

define('CITOMNI_START_NS', hrtime(true));
define('CITOMNI_ENVIRONMENT', 'dev');
define('CITOMNI_APP_PATH', dirname(__DIR__));



declare(strict_types=1);

return [
	'locale' => [
		'timezone' => 'Europe/Copenhagen',
		'charset' => 'UTF-8',
		'icu_locale' => 'da_DK',
	],
];

\CitOmni\Cli\Kernel::run(CITOMNI_APP_PATH . '/config', $_SERVER['argv'] ?? []);

$app = \CitOmni\Cli\Kernel::boot(CITOMNI_APP_PATH . '/config');

$commands = $app->commands;
$exitCode = $app->runner->run(['bin/citomni', 'app:info', '--json']);


declare(strict_types=1);

namespace App\Cli\Command;

use CitOmni\Kernel\Command\BaseCommand;

class GreetCommand extends BaseCommand {
	/**
	 * Declare the accepted command input.
	 *
	 * @return array<string, mixed> Command signature.
	 */
	protected function signature(): array {
		return [
			'arguments' => [
				'name' => [
					'description' => 'Name to greet',
					'default' => 'World',
				],
			],
			'options' => [
				'repeat' => [
					'short' => 'r',
					'type' => 'int',
					'default' => 1,
					'description' => 'Number of greetings',
				],
			],
		];
	}

	/**
	 * Print the greeting after input parsing succeeds.
	 *
	 * @return int Command exit code.
	 */
	protected function execute(): int {
		$name = $this->argString('name');
		$repeat = $this->getInt('repeat');

		if ($repeat < 1) {
			$this->error('--repeat must be at least 1.');
			return self::USAGE;
		}

		for ($i = 0; $i < $repeat; $i++) {
			$this->stdout("Hello, {$name}!");
		}

		return self::SUCCESS;
	}
}


declare(strict_types=1);

return [
	'app:greet' => [
		'command' => \App\Cli\Command\GreetCommand::class,
		'description' => 'Print a greeting.',
	],
];

return [
	'app:greet' => [
		'command' => \App\Cli\Command\GreetCommand::class,
		'description' => 'Print a greeting.',
		'options' => [],
	],
];


declare(strict_types=1);

namespace App\Boot;

class Registry {
	public const COMMANDS_CLI = [
		'app:greet' => [
			'command' => \App\Cli\Command\GreetCommand::class,
			'description' => 'Print a greeting.',
		],
	];
}


declare(strict_types=1);

return [
	\App\Boot\Registry::class,
];

$timezone = (string)($this->app->cfg->locale->timezone ?? 'UTC');


declare(strict_types=1);

return [
	'error_handler' => [
		'render' => [
			'trigger' => E_ALL,
			'detail' => [
				'level' => 1,
			],
		],
	],
];
bash
php bin/citomni
php bin/citomni list
php bin/citomni app:info
php bin/citomni app:info --help
bash
php bin/citomni app:greet
php bin/citomni app:greet Lars --repeat=3
php bin/citomni app:greet Lars -r 2
php bin/citomni app:greet --help
bash
php bin/citomni app:info
php bin/citomni app:info --json
php bin/citomni app:info --env-configs --json
bash
php bin/citomni cache:warm --mode=cli
php bin/citomni cache:warm --mode=all --env=prod --json
php bin/citomni cache:clear --mode=cli
php bin/citomni cache:clear --mode=http --json
bash
composer install --no-dev --optimize-autoloader
php bin/citomni cache:warm --mode=all --env=prod