imgurbot12/slap 问题修复 & 功能扩展

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

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

imgurbot12/slap

最新稳定版本:0.1.0

Composer 安装命令:

composer require imgurbot12/slap

包简介

A PHP CLI Library Inspired by Rust's CLAP

README 文档

README

A PHP CLI Library Inspired by Rust's CLAP

Installation

$ composer require imgurbot12/slap

Usage

Slap supports a standard CLI builder mode which returns an untyped array as a result:

use Imgurbot12\Slap\Arg;
use Imgurbot12\Slap\Command;
use Imgurbot12\Slap\Flag;

$app = Command::new('myapp')
  ->args(Arg::new('foo')->about('foo description'))
  ->flags(Flag::new('test')->short('t')->default('hello'))
  ->subcommands(
      Command::new('bar')->args(Arg::new('baz')->default('world'));

$result = $app->parse();
print_r($result);

It also includes a derivation mode similar to clap:

use Imgurbot12\Slap\Derive\Command;
use Imgurbot12\Slap\Derive\Flag;
use Imgurbot12\Slap\Derive\Parser;
use Imgurbot12\Slap\Derive\SubCommands;

#[Command(name: 'bar')]
class Bar {
  public string $baz = 'world';
}

class Commands extends SubCommands {
  public Bar $bar;
}

#[Command(name: 'myapp')]
class MyApp extends Parser {
  /** foo description */
  public string $foo;
  #[Flag(short: 't')]
  public string $test = 'hello';

  public Commands $command;
}

$result = MyApp::parse();
print_r($result);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固