Download the PHP package power-modules/console without Composer
On this page you can find all versions of the php package power-modules/console. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download power-modules/console
More information about power-modules/console
Files in power-modules/console
Package console
Short Description PowerModuleSetup extension that auto-discovers and registers Symfony Console commands from Power Modules.
License MIT
Informations about the package console
Console
A PowerModuleSetup extension for the Power Modules Framework that auto-discovers and registers Symfony Console commands from your modules.
Why a separate interface?
The framework's ExportsComponents is for sharing services between modules via ImportsComponentsSetup — it belongs to inter-module dependency wiring. Console commands are not services another module imports; they are an outward-facing capability of a module. This package introduces ProvidesConsoleCommands to express that cleanly, without conflating command registration with cross-module service sharing.
Installation
Quick Start
1. Create a command in your module:
2. Implement ProvidesConsoleCommands in your module:
3. Add the setup to your application:
4. Run your commands:
How It Works
ConsoleCommandsSetup uses the framework's two-phase setup lifecycle:
PRE phase — for each module implementing ProvidesConsoleCommands, iterates getConsoleCommands() and reads the #[AsCommand] attribute on each class to build a name → class-string command map.
POST phase — two steps:
-
Application registration (once, on the first module): creates a
ContainerCommandLoaderfrom the collected command map and registers aConsole\Applicationin the root container. If anApplicationis already present there (e.g. pre-registered by another module), it is reused rather than replaced. - Command bridging (per
ProvidesConsoleCommandsmodule): registers each command class in the root container, resolved from the module's own container. This keeps each command's DI wiring private to its module while making the command resolvable by theContainerCommandLoader.
Commands are lazily instantiated — the container resolves a command only when it is actually executed.
Requirements
- PHP: ^8.4
- power-modules/framework: ^2.1
- symfony/console: ^7.3
Architecture
- Modules declare commands via
ProvidesConsoleCommands::getConsoleCommands()— no need to also implementExportsComponents - Commands must extend
Symfony\Component\Console\Command\Command - Commands must carry the
#[AsCommand]attribute (provides the command name) - Dependencies are resolved from the module's own container via constructor injection
- The
Console\Applicationinstance is registered in the root container for retrieval
Contributing
Contributions are welcome. This project follows the same standards as the Power Modules Framework:
- PHPStan Level 8
- PHP CS Fixer
- PHPUnit
License
MIT License. See LICENSE for details.
Part of the Power Modules Framework ecosystem.