定制 arefshojaei/php-x 二次开发

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

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

arefshojaei/php-x

最新稳定版本:1.6.1

Composer 安装命令:

composer create-project arefshojaei/php-x

包简介

PHP Console application

README 文档

README

<?php

use PhpX\Components\Console\App;

$app = new App;

$app->command("welcome", function() {
    return "Welcome command!";
});

$app->launch();

Installation

Using Composer

composer create-project arefshojaei/php-x

Using GIT

git clone https://github.com/ArefShojaei/PhpX

Add Provider that run before exact command

# First method
$app->use(function() { ... });

# Second method
use PhpX\Components\Console\Provider;

class ExampleProvider extends Provider {
    public function handle() { ... }
}

$app->use(new ExampleProvider);

Add Command

# First method
$app->command("help", function() { ... });

# Second method
use PhpX\Components\Console\Command;

class ExampleCommand extends Command {
    public function exec() { ... }
}

$app->command("help", new ExampleCommand);

Get command params

  • [COMMAND] "users { id }"
  • [COMMAND] "help --{ command }"
  • [COMMAND] "link { url } { format }"
$app->command("users {id}", function($id) { ... });

$app->command("help {command}", function($command) { ... });

$app->command("link {url} {format}", function($url, $format) { ... });

Console Utility to show message with color

use PhpX\Utils\Console\Console;

echo Console::log("My message") . PHP_EOL; # [LOG] My message
echo Console::info("My message") . PHP_EOL; # [INFO] My message
echo Console::success("My message") . PHP_EOL; # [SUCCESS] My message
echo Console::warn("My message") . PHP_EOL; # [WARN] My message
echo Console::error("My message") . PHP_EOL; # [ERROR] My message

View Utility to show table content

use PhpX\Utils\View\ViewBuilder;

$app->command("welcome", function() {
    return (new ViewBuilder)
        ->addHeader()
        ->addCell(title: "Cell")
        ->addSeparator()
        ->addFooter()
        ->build();
});

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-28