Replacing dot-console with dot-cli based on laminas-cli

Implementing dot-cli in your application

DotKernel’s dot-cli package comes as a replacement for dot-console, which was abandoned after Laminas abandoned their laminas-console package, that dot-console was based on.


Install package

Run the following command in your application’s root directory:

composer require dotkernel/dot-cli

Register ConfigProvider

Open your application’s config/config.php file and add Dot\Cli\ConfigProvider::class, under the DK packages comment.

Create bootstrap file

Locate the provided vendor/dotkernel/dot-cli/bin/cli.php and copy it into your application’s bin directory.

This is the file you will execute your commands through.

Create config file

Locate the provided vendor/dotkernel/dot-cli/config/autoload/ and copy it into your application’s config/autoload directory.

This file already contains a sample command (demo:command), that serves as an example on creating an registering new commands.

For more information on configuring/chaining commands, see laminas-cli documentation.


Run the following command in your application’s root directory:

php ./bin/cli.php

The output should look similar to this, containing information on how to start using dot-cli:

DotKernel CLI 1.0.0

command [options] [arguments]

-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
help Display help for a command
list List commands
demo:command Demo command description.

Set up command as cronjob

Open your crontab and add the following line:

* * * * {PATH_TO_PHP_EXECUTABLE} {PATH_TO_APPLICATION}/bin/cli.php demo:command

Where {PATH_TO_PHP_EXECUTABLE} needs to replaced with the full path to the PHP executable and {PATH_TO_APPLICATION} with the full path to your application’s root directory.


dot-cli has a built-in locking system, called FileLocker, enabled by default. This feature prevents multiple calls to the same command overlapping eachother by making sure the latter calls won’t run until the former one is finished.

You can toggle this modifying in the previously created config/autoload/ under FileLockerInterface::class -> enabled

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>