Dotkernel component to build console applications based on laminas-cli, for any PSR-11 container.
dot-cli is a wrapper on top of laminas-cli
Documentation is available at: https://docs.dotkernel.org/dot-cli/.
| Version | Status | PHP | Documentation |
|---|---|---|---|
| 4.x | Active | 8.3, 8.4, 8.5, 8.6 | https://docs.dotkernel.org/dot-cli/v4/overview/ |
| 3.x | Security fixes only | 8.2, 8.3, 8.4, 8.5 | https://docs.dotkernel.org/dot-cli/v3/overview/ |
Upgrading from 3.x? Read the upgrade guide.
- PHP: 8.3, 8.4, 8.5 or 8.6
- laminas/laminas-cli: >= 1.16
- symfony/console and symfony/event-dispatcher: 7.4 or 8.x
- A PSR-11 container that reads
factoriesandaliasesconfiguration, for examplelaminas/laminas-servicemanager(require it in your application)
Run the following command in your application's root directory:
composer require dotkernel/dot-cliOpen your application's config/config.php and the following line under the DK packages comment:
Dot\Cli\ConfigProvider::class,Locate file bin/cli.php in this package, then copy it to your application's bin/ directory.
This is the bootstrap file you will use to execute your commands with.
Locate in this package the following file config/autoload/cli.global.php then copy it to your application's config/autoload/ directory.
This is the config file you will add your commands to, using the command name as the key:
'commands' => [
Dot\Cli\Command\DemoCommand::DEFAULT_NAME => Dot\Cli\Command\DemoCommand::class,
],The lock files are written to data/lock by default. Make sure the directory exists and is writable.
Using the command line, go to your application's root directory, then type the following command:
php ./bin/cli.phpThe output should look similar to this, containing information on how to start using dot-cli:
Dotkernel CLI 1.0.0
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
--silent Do not output any message
-q, --quiet Only errors are displayed. All other output is suppressed
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) 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:
completion Dump the shell completion script
help Display help for a command
list List commands
demo
demo:command Demo command description.
As shown in config/autoload/cli.global.php, dot-cli includes a demo command demo:command that will help you understand the basics of creating a new command.
For more information, see laminas-cli documentation.
* * * * * php /var/www/vhosts/example.com/httpdocs/bin/cli.php demo:command -q
or
* * * * * cd /var/www/vhosts/example.com/httpdocs/bin && php ./cli.php demo:command -q
Adapt the command to your specifications by replacing example.com with your domain name.
The -q (or --quiet) option suppresses normal output, but errors are still written to stderr, including the lock error shown when the previous run of the same command has not finished yet. Use --silent instead if you want no output at all.
MIT