Download the PHP package thesis/symfony-console-module without Composer
On this page you can find all versions of the php package thesis/symfony-console-module. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thesis/symfony-console-module
More information about thesis/symfony-console-module
Files in thesis/symfony-console-module
Package symfony-console-module
Short Description Thesis Symfony Console Module
License MIT
Informations about the package symfony-console-module
Thesis Symfony Console Module
A Thesis DIC module that integrates Symfony Console into your application.
Supports all registration features:
- invokable commands
- method-based commands
Symfony\Component\Console\Command\Commandsubclasses- lazy commands
#[Symfony\Component\Console\Attribute\AsCommand]attribute
Requirements
- PHP 8.4+
symfony/console^6 | ^7 | ^8
Installation
Quick start
Here's a console app built with Thesis Dic and Symfony Console Module:
Documentation
Importing SymfonyConsoleModule registers an Application and enables two tags that control how commands are added
to it.
Manual tagging
CommandTag marks any callable — an invokable class or a function — to be wrapped in a lazy command:
LegacyCommandTag marks a Command subclass. When name is provided, the command is wrapped in a LazyCommand
and loaded on demand. When name is omitted, the name is read from the command itself — which requires
instantiating it eagerly on application boot:
Autoconfiguration with #[AsCommand]
AutoconfigureCommands reads the native #[AsCommand] attribute and applies the appropriate tag automatically,
so you don't have to tag each class by hand.
Apply it once per module:
Invokable class — any class with #[AsCommand] and an __invoke() method gets a CommandTag:
Method-based commands — methods annotated with #[AsCommand] are picked up individually, which is convenient
when one class groups related commands:
Command subclass — classes that extend Command get a LegacyCommandTag. The name comes from #[AsCommand]
if present, otherwise from the name already set on the class: