1. Go to this page and download the library: Download mongdch/mon-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/ */
mongdch / mon-console example snippets
* 指令回调对象
*/
class Test extends \mon\console\Command
{
/**
* 执行指令
*
* @param \mon\console\Input $input 输入对象实例
* @param \mon\console\Output $output 输出对象实例
* @return void
*/
public function execute(Input $input, Output $output)
{
$name = $input->read('What\'s your name? ');
$password = $input->password();
return $output->write('Hello '.$name.', Your password is '.$password);
}
}
// 获取应用实例
$app = \mon\console\App::instance();
// 注册简单指令
$app->add('test', Test::class, 'This is Test Command!');
// 注册包含别名的指令
$app->add('demo', Test::class, ['alias' => 'd', 'desc' => 'This is Demo Command!']);
// 使用匿名方法作为指令回调
$app->add('hello', function($input, $output){
return $output->write('This is a Closure Command!');
});
// 运行指令
$app->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.