1. Go to this page and download the library: Download pollora/wp-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/ */
pollora / wp-cli example snippets
use Pollora\Attributes\WpCli;
use Pollora\Attributes\WpCli\Command;
use Pollora\Attributes\WpCli\Synopsis;
/**
* Manage the reports.
*/
#[WpCli]
final class ReportsCommand
{
public function __construct(private readonly ReportBuilder $reports) {}
/**
* Build a report.
*/
#[Command('build')]
#[Synopsis('<month> [--format=<format>]')]
public function build(array $arguments, array $options): void
{
WP_CLI::success($this->reports->build($arguments[0], $options['format'] ?? 'csv'));
}
#[Command('rm')]
public function deleteReport(array $arguments, array $options): void {}
}
use Pollora\Discovery\Domain\Models\DiscoveryLocation;
use Pollora\Discovery\Infrastructure\Services\DiscoveryEngine;
use Pollora\WpCli\Application\Services\WpCliService;
use Pollora\WpCli\Infrastructure\Adapters\WpCliAdapter;
use Pollora\WpCli\Infrastructure\Services\WpCliDiscovery;
if (defined('WP_CLI') && WP_CLI) {
(new DiscoveryEngine)
->addLocation(new DiscoveryLocation('MyPlugin\\', __DIR__.'/src'))
->addDiscovery('wp_cli_commands', new WpCliDiscovery(new WpCliService(new WpCliAdapter)))
->run();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.