Use Windwalker Console
Windwalker Console is a powerful CLI tool set to help us do many things. It is based on Windwalker Console Package.
To use Windwalker console, type this command in terminal:
php windwlaker
You will see this help information:
Windwalker Console - version: 3.x
------------------------------------------------------------
[windwalker Help]
The default application command
Usage:
windwalker <command> [option]
Options:
-h | --help Display this help message.
-q | --quiet Do not output any message.
-v | --verbose Increase the verbosity of messages.
--ansi Set 'off' to suppress ANSI colors on unsupported terminals.
-n | --no-interactive Ignore interactions and assume to default value.
Commands:
system System operation.
run Run custom scripts.
asset Asset management
migration Database migration system.
seed The data seeder help you create fake data.
package Package operations.
queue Queue management.
Welcome to Windwalker Console.
No Interactive
Add -n
or --no-interactive
that all commands wll ignore questions and use default vlaue.
Run Custom Scripts
Add a marco to console so we can batch run a set of commands.
Write your scripts in etc/config.yml
# ...
console:
script:
prepare:
- echo dev > .mode
- php windwalker asset sync admin
- php windwalker asset sync front
- php windwalker asset sync flower
- php windwalker migration reset
deploy:
- git pull
- composer install
- php windwalker run prepare
- php windwalker migration migrate
- php windwalker asset makesum
- echo prod > .mode
Then you can run your custom script by:
$ php windwalker run prepare
$ php windwalker run deploy
Auto Answer
If you wish your script can auto answer questions, you can use this format:
console:
script:
prepare:
- echo dev > .mode
- cmd: php windwalker migration drop-all
in: "y\nn\ny"
- php windwalker migration reset
Separate every answers by \n
(Must use double quote), so console will help you fill the input.
You must install
symfony/process
:~3.0
to support auto-answers.
Stop Running
By default, all commands no metter success or failure will not break script running.
If you want to stop batch running, just return code 64
in a command:
if (...)
{
return 64;
}
Or throw an exception with code 64
:
throw new \RuntimeException('...', 64);
List Scripts
Use $ php windwalker run --list
to list all scripts
Register Custom Command
You can add your custom command by editing etc/app/console.php
:
// ...
'console' => [
'commands' => [
'flower' => FlowerCommand::class
]
]
If you found a typo or error, please help us improve this document.