shiros/luna-console
Composer 安装命令:
composer require shiros/luna-console
包简介
Luna Module - Console
README 文档
README
# Luna Module - Console A PHP **Console Module** designed for managing and streamlining CLI operations in the **Luna Framework**. **Robust**, **Flexible**, and **Developer-Friendly** - Simplifying CLI-based workflow execution in your PHP projects.[[TOC]]
ℹ️ About the Project
This project is developed in PHP 8.2 and is part of the Luna Framework ecosystem.
The Luna Console Module facilitates command-line interactions by implementing tools and features that simplify CLI development.
Detailed documentation is available in the Wiki: Luna Wiki.
Key Features
- CLI Command Management: Facilitates the creation and management of CLI commands.
- Error Handling: Streamlined error reporting for smooth developer experience.
- Flexibility: Thin yet powerful integration with the Luna ecosystem for CLI workflows.
- PSR-4 Autoloading: Clean and autoloaded code structure.
- PHP 8.2 Features: Implements the latest PHP features, promoting clean, predictable code.
🔧 Dependencies
It uses PHP 8.2+, ensuring compatibility with modern features.
This module depends on the following:
- Luna Framework: The Luna framework's core. (MIT License)
- Development tools:
Refer to the composer.json file for additional details.
⚙️ Setup and Installation
To use the Luna Console module, follow the steps below:
Step 1: Install via Composer
Ensure Composer is installed, then execute the following in your root project folder:
composer require shiros/luna-console
Autoloading is handled by Composer (PSR‑4). When used within a Luna application, the module is auto‑discovered via
composer.json → luna.module:
{
"luna": {
"module": "Luna\\Console\\Module"
}
}
Step 2: Autoload the Module
The module supports PSR-4 autoloading. If you're using the Luna Framework, it’s automatically available via the Luna module declaration. Otherwise, make sure to include Composer’s autoloader:
require 'vendor/autoload.php';
🚀 Usage Example
Refer to the official documentation for advanced examples and further details.
Run the CLI
Here's a quick example of how to use the console to execute commands.
Go first in your project's directory.
cd <your_project_directory>;
Then, you could see which commands are available.
bin/console
To execute a command, follow the example below.
bin/console <my_command> [...args]
Create a command
Here's a quick example of a Luna command :
/**
* Represents the declaration of the Luna command.
*/
class TestCommand extends AbstractCommand
{
# --------------------------------
# Constants
// Arguments
protected const ARG_NAME = 'name';
# --------------------------------
# Configuration
/**
* @inheritDoc
*
* @throws CommandException
* @throws InputDefinitionException
*/
protected function configure(): void
{
$this
->setName(name: 'test:test')
->setDescription(description: 'This is a test command.')
->setDefinition([
new InputArgument(name: self::ARG_NAME, mode: InputArgument::OPTIONAL, default: 'First argument.')
])
;
}
# --------------------------------
# Core methods
/**
* @inheritDoc
*
* @throws ContainerException
* @throws DependencyInjectorException
* @throws ReflectionException
*/
protected function execute(
InputInterface $input,
OutputInterface $output
): int {
// ----------------
// Vars
// Get constants
$keyName = self::ARG_NAME;
// Get arguments
$name = $input->getArgument($keyName);
// ----------------
// Process
// Build the console UI
$ui = new OceanUI($input, $output);
// Display some texts
$ui
->section('Test - Display Argument')
->text('Hello world !')
;
// Display argument
if (!TypeManager::isEmpty($name)) {
$ui->text("- Argument '{$keyName}' : {$name}");
}
return 0;
}
}
Commands need to be registered in the configuration
config/services/consoleunder the sectionCommands
📄 Testing
This project uses PHPUnit for testing, you can run the test suite as follows.
Step 1: Install development dependencies
Before running the test suite, ensure all project dependencies, including development dependencies, are installed. Use Composer** to handle this:
composer install
This command will fetch all the required libraries and ensure your project setup is complete.
Step 2: Execute the Test Suite
Once dependencies are installed, you can execute the test suite using PHPUnit.
This ensures all the functionality of the framework is working as expected:
vendor/bin/phpunit --configuration phpunit.xml --colors=always
The test results will be displayed in your console. Colored output simplifies understanding the testing status:
- Green: Tests passed successfully.
- Red: Tests failed.
- Yellow: Warnings or skipped tests.
For more details on the tests, explore the /tests directory. It contains comprehensive unit tests covering various
parts of the framework.
📃 License
This project is licensed under the MIT License, allowing you to use and modify this project freely.
See the LICENSE file for more details.
👨💻 Authors and Contributors
This project was created and is maintained by Alexandre Caillot (Shiroe_sama), with contributions from the community.
Authors
Contributors
We thank the following contributors for making this project better:
shiros/luna-console 适用场景与选型建议
shiros/luna-console 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 90 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「php」 「module」 「console」 「php framework」 「ShirOS」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 shiros/luna-console 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shiros/luna-console 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 shiros/luna-console 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
Yii2 module to manage website content. Kind of a CMS...
Alfabank REST API integration
Codeurx Modular is simply a package for Laravel to help you create and manage modules.
User Module for the Attogram Framework
统计信息
- 总下载量: 90
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-07