Console Commands
MW_ENVIRONMENT={environment} bin/magework {package} {identifier} {args...}
To add a command to execute via CLI, add a new class in the Console
folder of your package.
Create a new class: packages/acme/app/Acme/Console/Date.php
<?php
declare(strict_types=1);
class Acme_Console_Date implements Core_Console_Interface
{
public function run(array $args): int
{
$format = $args[0] ?? 'Y-m-d H:i:s';
echo date($format) . "\n";
return self::SUCCESS;
}
}
Run the script via the command line:
bin/magework acme date "d/m/Y H:i"
The identifier contains underscore for deep classes.
The class Acme_Console_Customer_Clean
in packages/acme/app/Acme/Console/Customer/Clean.php
will be executed with:
bin/magework acme customer_clean