1. Go to this page and download the library: Download ssnepenthe/apheleia-cli library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ssnepenthe / apheleia-cli example snippets
use ApheleiaCli\Argument;
use ApheleiaCli\Command;
use ApheleiaCli\Option;
use WP_CLI;
class HelloCommand extends Command
{
public function configure(): void
{
$this->setName('example hello')
->setDescription('Prints a greeting.')
->addArgument(
(new Argument('name'))
->setDescription('The name of the person to greet.')
)
->addOption(
(new Option('type'))
->setDescription('Whether or not to greet the person with success or error.')
->setDefault('success')
->setOptions('success', 'error')
)
->setUsage("## EXAMPLES\n\n\twp example hello newman")
->setWhen('after_wp_load');
}
public function handle($args, $assocArgs)
{
[$name] = $args;
$type = $assocArgs['type'];
WP_CLI::$type("Hello, $name!");
}
}
use ApheleiaCli\CommandRegistry;
$registry = new CommandRegistry();
$registry->add(new HelloCommand());
$registry->initialize();
$registry->namespace('example', 'Implements example command.');
$registry->add(new HelloCommand());
class HelloCommand extends Command
{
public function configure(): void
{
$this->setName('hello')
// etc...
;
}
// ...
}
$registry->group('example', 'Implements example command.', function (CommandRegistry $registry) {
$registry->add(new HelloCommand());
});
$registry->add(
(new Command())
->setName('hello')
->setDescription('Prints a greeting.')
->addArgument(
(new Argument('name'))
->setDescription('The name of the person to greet.')
)
->addOption(
(new Option('type'))
->setDescription('Whether or not to greet the person with success or error.')
->setDefault('success')
->setOptions('success', 'error')
)
->setUsage("## EXAMPLES\n\n\twp example hello newman")
->setWhen('after_wp_load')
->setHandler(function ($args, $assocArgs) {
[$name] = $args;
$type = $assocArgs['type'];
WP_CLI::$type("Hello, $name!");
})
);