attreid/console

Nette Cli console with web interface

1.0.1 2023-03-15 08:18 UTC

This package is auto-updated.

Last update: 2024-12-15 12:09:34 UTC


README

Settings in config.neon

extensions:
    console: Atrreid\Console\DI\ConsoleExtension

available settings

console:
    prefix: cli
    collections:
        - ClassWithCommands

Add route

class RouterFactory
    public function __construct(private readonly \Attreid\Console\Routing\RouterFactory $consoleRouterFactory)
	{
	}

	public function createRouter(): RouteList
	{
		$router = new RouteList;
		$this->consoleRouterFactory->createRoutes($router);
		// other routes
}

Commands

class ClassWithCommands extends CommandCollection {

    /**
     * Comment, show in help
     * @param string $variable comment 
     */
    public function command(string $variable): void {
        $this->printLine('Some info');
        // php code
    }
}

Run

Run in console

php index.php ClassWithCommands:command /variable=value

or in browser with Tracy on

http://domain/cli/ClassWithCommands/command?variable=value