PHP code example of crodas / cli

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

    

crodas / cli example snippets



 = new crodas\cli\Cli("/tmp/some.cache.tmp");
// the vendors cli
$cli->addDirectory(__DIR__ . '/vendor');
// add my APP directory
$cli->addDirectory(__DIR__ . '/apps');

// run
$cli->main();


namespace myApp\Cli;

/**
 * @Cli("foobar", "some text to describe my app")
 * @Arg('name', OPTIONAL, 'add name')
 * @Option('foobar', VALUE_REQUIRED|VALUE_IS_ARRAY, 'add name')
 */
function foobar_main($input, $output)
{
    $arg = $input->getArgument('name');
    $opt = $input->getOption('foobar');
    $output->writeLn(json_encode(compact('arg', 'opt')));
}