hasan-22/php-command 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hasan-22/php-command

最新稳定版本:v1.0.0

Composer 安装命令:

composer require hasan-22/php-command

包简介

Creating custom commands by PHP

README 文档

README

Creating custom commands by PHP language With this package, you can easily create a command line script

Install

composer require hasan-22/php-console

Usage:

Create a command

use App\Console;

Console::command('command_name',function (){
    
})->purpose('Command description');

// purpose method is optional

// Run it like this
// php [scriptName.php] [command_name] [args]

Get input from user

Console::command('get_username',function (){
    $input = Console::input('Enter your name: ');
    echo $input;
})->purpose('This command gets the username');

// Run:
// php script.php get_username

Secret input

Console::command('get_password',function (){
    $input = Console::secretInput('Enter your password:');
    echo $input;
});

// Run:
// php script.php get_password

Get arguments for command line

Console::command('get_password',function (){
    $input = Console::option('--pass');
    echo $input;
});
// Run:
// php script.php get_password --pass 123456

// Output: 123456

##################### OR ########################
Console::command('get_password',function (){
    $input = Console::option('pass');
    echo $input;
});
// Run:
// php script.php get_password pass 123456

// Output: 123456

##################### OR ########################
Console::command('get_password',function (){
    $input = Console::option('pass');
    echo $input;
});
// Run:
// php script.php get_password pass=123456

// Output: 123456

Add color to text

Console::command('get_password',function (){
    $input = Console::option('--pass');
    echo Console::success($input);
    echo Console::error($input);
    echo Console::warning($input);
    echo Console::info($input);
    echo Console::none($input);
});

Help about commands

// script.php help
// or
//script.php --help
// or
//script.php -h
// or
//script.php h

Functions

Functions Description Example
Command Create a command Console::Command('commandName',Closure)
input It takes an input from the user and returns the value of the input Console::input('Your message')
secretInput User input will not be visible to them as they type in the console Console::secretInput('You password: ')
purpose Add a description to the command Console::purpose('Description')
option Takes the value of an argument Console::option('argName')

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固