承接 phpnomad/symfony-console-integration 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

phpnomad/symfony-console-integration

最新稳定版本:1.0.4

Composer 安装命令:

composer require phpnomad/symfony-console-integration

包简介

README 文档

README

Latest Version Total Downloads PHP Version License

Integrates Symfony Console with PHPNomad's console abstraction. Your commands implement phpnomad/console's Command interface and declare their arguments through PHPNomad's signature syntax. This package parses those signatures, registers the commands with a Symfony Application, and runs handle() through any declared middleware and interceptors. Your command classes never reference Symfony directly.

Installation

composer require phpnomad/symfony-console-integration

What This Provides

  • ConsoleStrategy parses a PHPNomad signature into Symfony InputArgument and InputOption definitions, wraps the command in an anonymous Symfony Command subclass, and runs handle() through any HasMiddleware and HasInterceptors hooks. ConsoleException failures are logged via LoggerStrategy and surfaced through OutputStrategy::error() with exit code 1.
  • ConsoleOutputStrategy maps writeln, info, success, warning, error, newline, and table onto a Symfony OutputInterface with blue, green, yellow, and red formatter styles.
  • Input wraps a Symfony InputInterface behind PHPNomad's Input contract, with an override map so middleware can mutate values without touching the Symfony request.
  • Initializer is a phpnomad/loader initializer that binds the strategies to their PHPNomad interfaces and provides a singleton Symfony OutputInterface (a ConsoleOutput with the default formatter).

Requirements

  • phpnomad/console, the contract this package implements
  • symfony/console ^7.2, the library this package bridges
  • phpnomad/logger for exception logging inside the command wrapper
  • phpnomad/utils and phpnomad/loader for bootstrapping

Usage

Bind a Symfony Application into your container, pass this package's Initializer to your Bootstrapper alongside any initializer that declares commands via HasCommands, then call run() on the resolved ConsoleStrategy:

<?php

use MyApp\Commands\CommandsInitializer;
use PHPNomad\Console\Interfaces\ConsoleStrategy;
use PHPNomad\Loader\Bootstrapper;
use PHPNomad\Symfony\Component\Console\Initializer as SymfonyConsoleInitializer;
use Symfony\Component\Console\Application;

require __DIR__ . '/../vendor/autoload.php';

$container = require __DIR__ . '/../bootstrap/container.php';

$container->bindSingletonFromFactory(
    Application::class,
    fn() => new Application('MyApp CLI')
);

$bootstrapper = new Bootstrapper(
    $container,
    new SymfonyConsoleInitializer(),
    new CommandsInitializer()
);

$bootstrapper->load();

$container->get(ConsoleStrategy::class)->run();

CommandsInitializer is any class implementing HasCommands. Its getCommands() returns an array of command class names, and the loader registers each one automatically. Each command class implements Command, with getSignature() returning a string like widget:create {name:The widget name} {--force} and handle(Input $input) running the work.

Documentation

PHPNomad documentation lives at phpnomad.com. For the underlying library, see the Symfony Console documentation.

License

Licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固