1. Go to this page and download the library: Download danack/console 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/ */
danack / console example snippets
$console = new Application();
$console->add(new AboutCommand());
// Create a command that will call the function 'uploadFile'
$uploadCommand = new Command('uploadFile', 'upload');
$uploadCommand->addArgument('name', InputArgument::REQUIRED, 'The name of the thing to foo');
$console->add($uploadCommand);
$helloWorldCallable = function ($name) {
echo "Hello world, and particularly $name".PHP_EOL;
};
// Create a command that will call the closure
$callableCommand = new Command($helloWorldCallable, 'greet');
$callableCommand->addArgument('name', InputArgument::REQUIRED, 'The name of the person to say hello to.');
$console->add($callableCommand);
try {
$parsedCommand = $console->parseCommandLine();
}
catch (\Exception $e) {
$output = new BufferedOutput();
$console->renderException($e, $output);
echo $output->fetch();
exit(-1);
}
$provider = new Auryn\Provider();
$provider->execute(
$parsedCommand->getCallable(),
lowrey($parsedCommand->getParams())
);
function uploadFile($filename) {
echo "Need to upload the file $filename".PHP_EOL;
}
// Auryn needs scalars prefixed with a colon
function lowrey($params) {
$newParams = [];
foreach ($params as $key => $value) {
$newParams[':'.$key] = $value;
}
return $newParams;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.