定制 stk2k/argparser 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

stk2k/argparser

Composer 安装命令:

composer require stk2k/argparser

包简介

Parser for command line options

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Code Climate Total Downloads

Description

Parser for command line options

Feature

  • No need to setup complex configuration
  • short options: -abc means a/b/c switches(returns [a=>true, b=>true, c=>true])
  • long options: --a-key value/--a-key=value returns associative array(['a-key'=>value])
  • ordered options: "command a b c" returns ordered array([a, b, c])

Parameters

ArgParser::parse(array $args = null, array $required =[], array $defaults = []);
arg name explain
$args specify arguments(if omitted, global $argv is used)
$required specify required options
$defaults specify option default values

Demo

[01] Parse command line

use stk2k\argparser\ArgParser;

$args = ArgParser::parse();     // script.php a b -c --favorite-food="Fried potato"
print_r($args);
//Array
//(
//    [0] => /path/to/script.php
//    [1] => a
//    [2] => b
//    [-c] => 1
//    [--favorite-food] => Fried potato
//)

Requirement

PHP 7.2 or later

Installing stk2k/argparser

The recommended way to install stk2k/argparser is through Composer.

composer require stk2k/argparser

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

License

MIT

Author

stk2k

Disclaimer

This software is no warranty.

We are not responsible for any results caused by the use of this software.

Please use the responsibility of the your self.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固