PHP code example of cli / terminal

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

    

cli / terminal example snippets


use Butschster\Commander\SDK\Builder\ApplicationBuilder;
use Butschster\Commander\Module\FileBrowser\FileBrowserModule;

$app = ApplicationBuilder::create()
    ->withModule(new FileBrowserModule())
    ->withInitialScreen('file_browser')
    ->build();

$app->run();

#!/usr/bin/env php


declare(strict_types=1);

ilder;
use Butschster\Commander\Module\FileBrowser\FileBrowserModule;
use Butschster\Commander\Module\CommandBrowser\CommandBrowserModule;
use Butschster\Commander\Module\ComposerManager\ComposerModule;
use Butschster\Commander\Module\Git\GitModule;
use Butschster\Commander\UI\Theme\ColorScheme;
use Butschster\Commander\UI\Theme\MidnightTheme;
use Symfony\Component\Console\Application as SymfonyApplication;

// 1. Create Symfony Console Application (for command browser)
$symfonyApp = new SymfonyApplication('My App', '1.0.0');

// 2. Apply theme
ColorScheme::applyTheme(new MidnightTheme());

// 3. Build application with modules
$app = ApplicationBuilder::create()
    ->withModule(new FileBrowserModule())
    ->withModule(new CommandBrowserModule($symfonyApp))
    ->withModule(new ComposerModule(getcwd()))
    ->withModule(new GitModule())
    ->withInitialScreen('file_browser')
    ->build();

// 4. Run
$app->run();

use Butschster\Commander\UI\Theme\MidnightTheme;
ColorScheme::applyTheme(new MidnightTheme());

use Butschster\Commander\UI\Theme\DarkTheme;
ColorScheme::applyTheme(new DarkTheme());

use Butschster\Commander\UI\Theme\LightTheme;
ColorScheme::applyTheme(new LightTheme());

use Butschster\Commander\Module\FileBrowser\FileBrowserModule;

->withModule(new FileBrowserModule('/path/to/start'))

use Butschster\Commander\Module\CommandBrowser\CommandBrowserModule;

->withModule(new CommandBrowserModule($symfonyApp))

use Butschster\Commander\Module\ComposerManager\ComposerModule;

->withModule(new ComposerModule('/path/to/project'))

use Butschster\Commander\Module\Git\GitModule;

->withModule(new GitModule('/path/to/repo'))



declare(strict_types=1);

namespace MyApp\Module\Todo;

use Butschster\Commander\SDK\Module\ModuleInterface;
use Butschster\Commander\SDK\Module\ModuleMetadata;
use Butschster\Commander\SDK\Module\ModuleContext;
use Butschster\Commander\SDK\Provider\ScreenProviderInterface;
use Butschster\Commander\SDK\Container\ContainerInterface;

final readonly class TodoModule implements ModuleInterface, ScreenProviderInterface
{
    public function metadata(): ModuleMetadata
    {
        return new ModuleMetadata(
            name: 'todo',
            title: 'Todo Manager',
            version: '1.0.0',
        );
    }

    public function screens(ContainerInterface $container): iterable
    {
        yield new TodoScreen();
    }

    public function boot(ModuleContext $context): void
    {
        // Initialize module
    }

    public function shutdown(): void
    {
        // Cleanup
    }
}

$app = ApplicationBuilder::create()
    ->withModule(new FileBrowserModule())
    ->withModule(new TodoModule())  // Your custom module
    ->withInitialScreen('todo')
    ->build();