PHP code example of clarity / console

1. Go to this page and download the library: Download clarity/console 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/ */

    

clarity / console example snippets




use Clarity\Console\Brood;

class SampleConsole extends Brood
{
    protected $alias = 'sample';
    protected $description = 'Just a sample class to test console';

    public function slash()
    {
        $this->comment('triggered!');
    }
}

#!/usr/bin/env php


$consoles = [
    SampleConsole::class,
];

use Symfony\Component\Console\Application;
$app = new Application(
    'Brood (c) Daison Cariño',
    'v0.0.1'
);

# let's check if the call came from CLI
if ( php_sapi_name() === 'cli' ) {

    # iterate the consoles array
    foreach ($consoles as $console) {
        $app->add(new $console);
    }
}

$app->run();
shell
php console