1. Go to this page and download the library: Download hanneskod/comphlete 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/ */
hanneskod / comphlete example snippets
$application = new \Symfony\Component\Console\Application();
$application->add(new \hanneskod\comphlete\Symfony\ComphleteCommand);
$application->run();
namespace hanneskod\comphlete;
$definition = (new Definition)
// first argument with a fixed set of suggestions
->addArgument(0, ['foo', 'bar', 'baz'])
// second argument with a dynamic callback
->addArgument(1, function () {
// load suggestions from database...
return ['aa', 'bb'];
})
// simple option
->addOption('foo')
// option with suggested values
->addOption('bar', ['val1', 'val2'])
;
$completer = new Completer($definition);
$input = (new InputFactory)->createFromArgv($argv);
echo Helper::dump($completer->complete($input));
$import = (new ContextDefinition('import'))
->addArgument(1, ['some-argument'])
;
$export = (new ContextDefinition('export'))
->addArgument(1, ['another-argument'])
;
$def = (new ContextContainerDefinition)
->addContext($import)
->addContext($export)
;
$completer = new Completer($def);
$input = (new InputFactory)->createFromArgv($argv);
echo Helper::dump($completer->complete($input));