1. Go to this page and download the library: Download amsify42/php-command-line 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/ */
amsify42 / php-command-line example snippets
use \Amsify42\CommandLine\CommandLine;
CommandLine::getParams();
cli_get_params();
CommandLine::getParam('id');
cli_get_param('id');
CommandLine::isParam('id');
cli_is_param('id');
echo CommandLine::toString();
echo cli_to_string();
namespace App\Task;
use Amsify42\CommandLine\Task\BaseTask;
class Test extends BaseTask
{
public function init()
{
printMsg("Doing something");
}
}
namespace App\Task;
use Amsify42\CommandLine\Task\BaseTask;
class Test extends BaseTask
{
public function init()
{
$id = $this->input('id');
$name = $this->input('name');
// do the remaining
}
}
public function init()
{
$this->validate(['id', 'name']);
// do the remaining
}