PHP code example of danc0 / dcli

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

    

danc0 / dcli example snippets


#!/usr/bin/php


if (php_sapi_name() !== 'cli') {
    exit;
}

 // Process the config
use App\Core\Command_Request; // Process the Request
use App\Core\Command_Container; // Stores the config and request environment
use App\IO\Output;

// Get any user set config values
$config = Config::load(__DIR__ . '/App/config.ini')->get();

// Load the request into the Command_Container
$Command_Request   = new Command_Request($argv);
$Command_Container = new Command_Container($config, $Command_Request->process());

// Load the Application
$app = Application::load($Command_Container);

// Set the commands
$app->set('hello-world', function () {
    Output::message('Hello World');
});

// Run the Application
$app->run();


#!/usr/bin/php


if (php_sapi_name() !== 'cli') {
    exit;
}

 // Process the config
use App\Core\Command_Request; // Process the Request
use App\Core\Command_Container; // Stores the config and request environment
use App\IO\Output;
use App\Commands\Hello\Test;

// Get any user set config values
$config = Config::load(__DIR__ . '/App/config.ini')->get();

// Load the request into the Command_Container
$Command_Request   = new Command_Request($argv);
$Command_Container = new Command_Container($config, $Command_Request->process());

// Load the Application
$app = Application::load($Command_Container);

// Set the commands
$app->set('hello-world', Test::class . '@test');

// Run the Application
$app->run();

#!/usr/bin/php


if (php_sapi_name() !== 'cli') {
    exit;
}

 // Process the config
use App\Core\Command_Request; // Process the Request
use App\Core\Command_Container; // Stores the config and request environment

// Get any user set config values
$config = Config::load(__DIR__ . '/App/config.ini')->get();

// Load the request into the Command_Container
$Command_Request   = new Command_Request($argv);
$Command_Container = new Command_Container($config, $Command_Request->process());

// Load the Application
$app = Application::load($Command_Container);

// Run the Application
$app->run();
Default_Handler.php
Test.php