attreid/console

Nette Cli console with web interface

Installs: 36

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/attreid/console

1.0.2 2026-02-06 09:18 UTC

This package is auto-updated.

Last update: 2026-02-06 10:36:51 UTC


README

Requirements: PHP 8.4+

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

Development / Docker

Build and run the PHP 8.4 CLI container:

docker compose up -d
docker compose exec php composer install
docker compose exec php composer test
docker compose exec php php index.php ClassWithCommands:command /variable=value

One-off run (e.g. install and test without keeping container):

docker compose run --rm php composer install
docker compose run --rm php composer test

Tests

  • In Docker (recommended):
docker compose run --rm php composer test
docker compose run --rm php composer test:coverage
  • Locally (if you have PHP 8.4 + Composer):
    • Run tests: composer test
    • Run tests with coverage: composer test:coverage (generates coverage.html)