PHP code example of websk / php-console

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

    

websk / php-console example snippets




use GetOpt\Command;
use GetOpt\GetOpt;
use Psr\Container\ContainerInterface;
use WebSK\Console\ConsoleApp;

hrow new InvalidArgumentException("Unknown service: {$id}");
    }

    public function has(string $id): bool
    {
        return false;
    }
};

$app = new ConsoleApp($container);
$app->addCommand(new Command(
    'hello',
    static function (GetOpt $getOpt): void {
        echo "Hello!\n";
    }
));

$app->execute();
shell
php console.php hello