PHP code example of kaiseki / wp-cli-util

1. Go to this page and download the library: Download kaiseki/wp-cli-util 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/ */

    

kaiseki / wp-cli-util example snippets


use Kaiseki\WordPress\WpCli\Util\Colorizer;

$c = new Colorizer();
echo $c->toGreen('done');
echo $c->toRedBright('failed');
echo $c->toBackgroundYellow('note');

use Kaiseki\WordPress\WpCli\Util\Logger;

$log = new Logger(new Colorizer());
$log->start('Importing posts');
$log->info('Found 120 items', indent: true);
$log->success('Done');
$log->warning('Skipped 3');
$log->error('Could not connect');

use Kaiseki\WordPress\WpCli\Util\TimerBuilder;

$timer = (new TimerBuilder())->make();
$timer->startTimer();
// … work …
echo $timer->getElapsedTimeString();  // e.g. "1m 12s"

$timer->addInterval();
// … more work …
echo $timer->getIntervalTimeString(); // time since the last interval