Download the PHP package baethon/symfony-console-input without Composer
On this page you can find all versions of the php package baethon/symfony-console-input. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download baethon/symfony-console-input
More information about baethon/symfony-console-input
Files in baethon/symfony-console-input
Package symfony-console-input
Short Description Generates command signature based on an input DTO
License MIT
Informations about the package symfony-console-input
Symfony Console Input Plugin
This project provides a streamlined way to define Symfony Console commands using PHP attributes and Data Transfer Objects (DTOs). It simplifies the configuration of arguments and options by leveraging metadata annotations, making it easier to maintain and extend console commands.
Features
- Automatically generates command arguments and options from DTO properties.
- Supports metadata annotations (
#[Argument]
,#[Option]
, etc.) to define command inputs. - Easily integrates with Symfony's Console component.
- Provides a
UsesInputData
trait to configure and initialize input data automatically.
Requirements
- PHP >= 8.4
Installation
To install the plugin, use Composer:
Getting Started
1. Define Your Input DTO
Create a class with properties annotated using provided attributes like #[Argument]
or #[Option]
.
[!IMPORTANT] The input class must define all arguments and options in the constructor.
2. Create a Command
Use the UsesInputData
trait in your Symfony Console command class to leverage the input configuration:
Attributes
#[Argument]
Marks a property as a required/optional argument.
#[Option]
Marks a property as an option.
#[Shortcut]
Defines a shortcut for an option.
#[Description]
Adds a description for the argument or option.
#[Name]
Sets a different name for the argument or option.
Testing
Run tests using Pest:
License
This project is licensed under the MIT License. See the LICENSE file for details.