Skip to content

Extending minicli



A tiny curl client built for Minicli (but can be also used standalone).

Requires curl and php-curl.

To include it in your app, first require the dependency with Composer:

composer require minicli/curly

The following single-command demo application will fetch a user's latest stats from using Curly:

#!/usr/bin/env php
if (php_sapi_name() !== 'cli') {

require __DIR__ . '/vendor/autoload.php';

use Minicli\App;
use Minicli\Exception\CommandNotFoundException;
use Minicli\Curly\Client;

$app = new App([
    'debug' => true,
    'theme' => '\Unicorn'

$app->registerCommand('devto', function () use ($app) {
    $app->getPrinter()->display('Fetching from DEV...');
    $crawler = new Client();

    $articles_response = $crawler->get('');

    if ($articles_response['code'] !== 200) {
        $app->getPrinter->error('Error while contacting the API.');
        return 1;

    $articles = json_decode($articles_response['body'], true);
    $table[] = ['Title', 'Reactions'];
    foreach($articles as $article) {
        $table[] = [$article['title'], $article['positive_reactions_count']];
    return 0;

try {
} catch (CommandNotFoundException $notFoundException) {
    $app->getPrinter()->error("Command Not Found.");
    return 1;

return 0;



A small-footprint, file-based JSON cache that can be used standalone or within Minicli apps.

Requires php-json.

use Minicli\Minicache\FileCache;

$cache = new FileCache($cache_file_path, $cache_expiry_in_seconds);
$cache_id = "unique-content-identifier";

//saving cache
$cache->save(json_encode($mydata), $cache_id);

//obtaining cached content that is not expired yet
$cached_content = $cache->getCachedUnlessExpired($cache_id);