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/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/Console/Customer/Clean.php will be executed with:
bin/magework Acme customer_clean
- Installation
- Configuration
- Add a new package
- Add a new HTML page
- Serve any type of file
- Rewrite a route
- Add a new block
- Data assignment
- Objects and class fallback
- Database
- Console Commands
- Framework tools
- Custom shared libraries
- External libraries with composer
- Templating best practices
- Forms
- Captcha
- Write content in Markdown
- Static Site Generator