PHP code example of weebel / console

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

    

weebel / console example snippets

 
#!/usr/bin/env php


el\Console\CommandContainer::getInstance();

$commandContainer->register(ExampleCommand::class);

$container = \Illuminate\Container\Container::getInstance();

 \Weebel\Console\StandAlone\ConsoleKernelBooter::start($container);
 


namespace App;

use Weebel\Console\Command;
use Weebel\Console\Concerns\HasClimate;

class GreetingCommand extends Command
{
    use HasClimate;

    public const NAME = 'app:greeting';
    public const DESCRIPTION = 'Saying good morning in some languages';

    protected array $validOptions = [
        'lang'  => 'Language for greeting | Optional'
    ];

    public function __invoke(string $name)
    {
        switch ($this->lang) {
            case 'en':
                $greeting = "Good morning";
                break;
            case 'nl':
                $greeting = "Goede morgen";
                break;
            case 'de':
                $greeting = "Guten Tag";
                break;
            default:
                $greeting = "Good morning";
                break;
        }
        
        $this->out("$greeting $name");
    }
}

 
$this->red('This text will be displayed in red');
$this->yellow('This text will be displayed in yellow');
 
$this->bold('This text will be displayed in bold');
$this->italic('This text will be displayed in italic');
$this->underline('This text will be displayed underlined'); 
 
$this->tab(2)->out('This message will be displayed with two tabs');
 
$this->out('This message will be displayed')->br()->out('on a new line');
 
#!/usr/bin/env php


ntDispatcher\EventDispatcher;
use Weebel\Console\CommandContainer;
use Weebel\Console\StandAlone\ConsoleKernelBooter;
use Illuminate\Container\Container;

$commandContainer = CommandContainer::getInstance();
$commandContainer->register(GreetingCommand::class);

$container = Container::getInstance();

$dispatcher = new EventDispatcher();

ConsoleKernelBooter::start($container, $dispatcher);