phil / console-bundle
Safer Symfony console commands: #[ForbidEnvironment] refusing a command in the listed kernel environments, #[ConfirmEnvironment] asking for the environment's name before it runs, --timestamps prefixing each output line with the time, --debug-phil printing the debug logs of chosen channels, a time an
Package info
github.com/parler-haut-interagir-librement/console-bundle
Type:symfony-bundle
pkg:composer/phil/console-bundle
Requires
- php: >=8.5
- psr/clock: ^1.0
- psr/container: ^2.0
- symfony/config: ^8.2
- symfony/console: ^8.2
- symfony/dependency-injection: ^8.2
- symfony/event-dispatcher: ^8.2
- symfony/service-contracts: ^3.6
Requires (Dev)
- monolog/monolog: ^3.0
- phpunit/phpunit: ^13.4
- psr/log: ^3.0
- roave/security-advisories: dev-latest
- symfony/clock: ^8.2
- symfony/framework-bundle: ^8.2
- symfony/http-kernel: ^8.2
- symfony/monolog-bundle: ^4.1
- symfony/stopwatch: ^8.2
Suggests
- monolog/monolog: For the --debug-phil option, which prints the debug logs of selected channels
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-11 13:29:57 UTC
README
Safer Symfony console commands
phil/console-bundle guards the commands that must not run anywhere, or not without a second thought:
#[ForbidEnvironment('prod')] refuses a command in the listed kernel environments, and #[ConfirmEnvironment('prod')]
asks for the environment's name before it runs and refuses a non-interactive run unless --force-environment is given.
Every command gets --timestamps, which puts the time before each line it writes, and, with Monolog, --debug-phil,
which prints the debug logs of chosen channels. A summary of the command's duration, memory and exit code is written at
its end, and lint:console-guards lists the guarded commands. Nothing is kept between two commands: a long-running
process runs each one afresh.
Status
| Part | State |
|---|---|
#[ForbidEnvironment] and #[ConfirmEnvironment] on classes, __invoke() and method-level commands |
Implemented and tested |
--force-environment for non-interactive runs, exit code 77 on a refusal |
Implemented and tested |
--timestamps in ISO 8601 or relative to the start, or by configuration |
Implemented and tested |
--debug-phil with Monolog channels |
Implemented and tested |
| The duration and memory summary | Implemented and tested |
lint:console-guards as a table or JSON |
Implemented and tested |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements, the bundle, worker mode. |
| Configuration | Every option, with an example. |
| Guarding commands | The two attributes, the confirmation, the exit code, the lint command. |
| Output | The timestamps, the debug logs, the summary. |
| Extension points | The debug switch, the memory gauge, the clock. |
| Testing | The bundle's tests and its benchmark. |
| Reference | Every class of the bundle. |
Quick start
// config/bundles.php Phil\ConsoleBundle\PhilConsoleBundle::class => ['all' => true],
use Phil\ConsoleBundle\Domain\Attribute\ConfirmEnvironment; use Phil\ConsoleBundle\Domain\Attribute\ForbidEnvironment; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand('app:database:reset')] #[ForbidEnvironment('prod', 'staging')] final class ResetDatabase { public function __invoke(): int } #[AsCommand('app:customers:anonymize')] final class AnonymizeCustomers { #[ConfirmEnvironment('prod')] public function __invoke(): int }
bin/console app:customers:anonymize --timestamps=relative --debug-phil=doctrine -v bin/console app:customers:anonymize --no-interaction --force-environment bin/console lint:console-guards
Requirements
PHP 8.5 or later and Symfony 8.2 or later; Monolog for --debug-phil.
Contributing
Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.
License
MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See LICENSE.