CLI "The command does not exist"

Hi,

I am trying to create some cli commands, but fail.

$ composer require getkirby/cli
$ vendor/bin/kirby

list the available commands, but creating my own does not work, neither from within a plugin[1] or from a file inside the site/commands directory[2].

When using the make command

$ vendor/bin/kirby make:command

the command file is created and stored in vendor/getkirby/site/commands/, calling vendor/bin/kirby now results in showing the new command at the end of the list

$ vendor/bin/kirby
… 
- kirby uuid:remove
- kirby version

Custom commands:
- kirby test-foo

The command work as expected

$ vendor/bin/kirby test-foo
Nice command!

Whats the trick here? What have i missed? I am wondering why the working directory is set to ./vendor/getkirby and not ./

Thanks and have a nice day

ciao, Stefan

[1] Commands | Kirby CMS
[2] GitHub - getkirby/cli: Kirby Command Line Interface

OK, got it.

my file structure is:

./
β”œβ”€β”€ composer.json
β”œβ”€β”€ composer.lock
β”œβ”€β”€ content
β”œβ”€β”€ site
β”œβ”€β”€ vendor
└── web (public)

Solution:
According to vendor/getkirby/cli/bootstrap.php, my β€œweb” should be one of the $locations

function index(): string|null
{
	$locations = [
		'./',
		'./web', // <- adding my "public" dir works.
		'./www',
		'./public',
		'./public_html'
	];
       // …
}

I see, guessing where the index.php is placed is not that easy.

Thanks and have a nice day.

Before it is misunderstood, this was of course only for testing and not my solution, the solution was to rename β€œweb” to β€œpublic”. :slight_smile:

1 Like