PHP code example of beauty-framework / cli

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

    

beauty-framework / cli example snippets


#!/usr/bin/env php


use Beauty\Cli\ConsoleKernel;

_DIR__ . '/config/cli.php';

$kernel = new ConsoleKernel($commands);
exit($kernel->run($argv));

return [
    \Beauty\Cli\Commands\VersionCommand::class,
    \Beauty\Cli\Commands\Generate\ControllerCommand::class,
    \App\Console\Commands\MyCommand::class,
];

return array_merge(
    [
        \Beauty\Cli\Commands\HelpCommand::class,
    ],
    \Beauty\Orm\OrmCommands::get(),
    \Beauty\Cache\CacheCommands::get(),
);

class MyCommand extends AbstractCommand {
    public function name(): string 
    {
        return 'my:command';
    }
    
    public function description(): string 
    {
        return 'Do something cool';
    }

    public function handle(array $args): int 
    {
        CliOutput::success('It worked!');
        return 0;
    }
}

CliOutput::info("Info message");
CliOutput::warn("Warning");
CliOutput::success("Done");
CliOutput::error("Something broke");
CliOutput::table(['ID', 'Name'], [[1, 'User'], [2, 'Admin']]);
bash
php beauty generate:controller User
php beauty generate:command SyncOrders
php beauty generate:middleware Auth
php beauty generate:request Hello
bash
php beauty generate:controller Admin/User