PHPackages                             digitalrevolution/symfony-console-validation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. digitalrevolution/symfony-console-validation

ActiveLibrary[CLI &amp; Console](/categories/cli)

digitalrevolution/symfony-console-validation
============================================

Symfony command input argument and option validation

v2.0.0(4mo ago)748.8k—2.8%1[1 PRs](https://github.com/123inkt/symfony-console-validation/pulls)MITPHPPHP &gt;=8.1CI passing

Since Jul 4Pushed 3mo agoCompare

[ Source](https://github.com/123inkt/symfony-console-validation)[ Packagist](https://packagist.org/packages/digitalrevolution/symfony-console-validation)[ RSS](/packages/digitalrevolution-symfony-console-validation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (11)Versions (5)Used By (0)

[![Minimum PHP Version](https://camo.githubusercontent.com/230588f62e4b3ba29858fcfcf1bbfe253f82c4180088091d6c7d4c6c06d80145/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e312d383839324246)](https://php.net/)[![Minimum Symfony Version](https://camo.githubusercontent.com/992497ffd816cda0638ec1832ef1c6caac7185ddaa96a96d79f85e8f2ddf4880/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73796d666f6e792d253345253344253230362e322d627269676874677265656e)](https://symfony.com/doc/current/validation.html)[![Run checks](https://github.com/123inkt/symfony-console-validation/actions/workflows/test.yml/badge.svg)](https://github.com/123inkt/symfony-console-validation/actions/workflows/test.yml/badge.svg)

Symfony Console Validation
==========================

[](#symfony-console-validation)

An input validation component for Symfony Console. Ease the validation of input arguments and options.

Installation
------------

[](#installation)

Include the library as dependency in your own project via:

```
composer require digitalrevolution/symfony-console-validation

```

Usage
-----

[](#usage)

1. Create your own `ExampleInput` class which extends the `AbstractValidatedInput` class.
2. Configure your own `ValidationRules`. See the [Validation shorthand library](https://github.com/123inkt/symfony-validation-shorthand) for more information about the rules.
3. Ensure the `InputValidator` class is registered as [service in your Symfony project](https://symfony.com/doc/current/service_container.html).

```
use DigitalRevolution\SymfonyConsoleValidation\AbstractValidatedInput;
use DigitalRevolution\SymfonyConsoleValidation\ValidationRules;

class ExampleInput extends AbstractValidatedInput
{
    public static function getValidationRules(): ValidationRules
    {
        return new ValidationRules([
            'arguments' => [
                'email'   => 'required|string|email'
            ],
            'options' => [
                'projectId' => 'int:min:1'
]
        ]);
    }

    public function getEmail(): string
    {
        return $this->input->getArgument('email');
    }

    public function getProjectId(): ?int
    {
        $value = $this->input->getOption('projectId');

        return $value === null ? null : (int)$value;
    }
}
```

All that remains is using your `ExampleInput` class in your `Command` to validate the input.

```
class ExampleCommand extends Command
{
    public function __construct(private InputValidator $inputValidator, ?string $name = null)
    {
        parent::__construct($name);
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        // third argument will throw exception if input is invalid. Set to `false` if you want to handle the validation yourself.
        $validatedInput = $this->inputValidator->validate($input, ExampleInput::class, true);

        ...
    }
}
```

Manual invalid input handling
-----------------------------

[](#manual-invalid-input-handling)

The `validate` method will by default throw a `ViolationException`. To handle the violations yourself:

```
class ExampleCommand extends Command
{
    ...

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $validatedInput = $this->inputValidator->validate($input, ExampleInput::class, false);
        if ($validatedInput->isValid() === false) {
            $violations = $validatedInput->getViolations();
            ...
        }
        ...
    }
}
```

About us
--------

[](#about-us)

At 123inkt (Part of Digital Revolution B.V.), every day more than 50 development professionals are working on improving our internal ERP and our several shops. Do you want to join us? [We are looking for developers](https://www.werkenbij123inkt.nl/zoek-op-afdeling/it).

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance78

Regular maintenance activity

Popularity35

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 79.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~638 days

Total

3

Last Release

139d ago

Major Versions

v1.1.0 → v2.0.02025-12-31

PHP version history (2 changes)v1.0.0PHP &gt;=8.0

v1.1.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/fe1034dcdc9935e9b7f7a733490a5095282445a8526e30e9097e0782c78e24c1?d=identicon)[bram123](/maintainers/bram123)

![](https://www.gravatar.com/avatar/d144b8d21d1631a75230f12330a9cb0ef6608581a5e6989c18677ac52295e271?d=identicon)[FrankDekker](/maintainers/FrankDekker)

![](https://www.gravatar.com/avatar/20e2ae81f6cffdb8c1b1a488b7f2f70270a5d1bf2a57aae09950697ac0ef3dad?d=identicon)[123Tim](/maintainers/123Tim)

---

Top Contributors

[![frankdekker](https://avatars.githubusercontent.com/u/2179983?v=4)](https://github.com/frankdekker "frankdekker (47 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (8 commits)")[![bram123](https://avatars.githubusercontent.com/u/7457368?v=4)](https://github.com/bram123 "bram123 (4 commits)")

---

Tags

commandconsoleinputsymfonyvalidation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/digitalrevolution-symfony-console-validation/health.svg)

```
[![Health](https://phpackages.com/badges/digitalrevolution-symfony-console-validation/health.svg)](https://phpackages.com/packages/digitalrevolution-symfony-console-validation)
```

###  Alternatives

[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[n98/magerun

Tools for managing Magento projects and installations

1.4k264.7k7](/packages/n98-magerun)[crazywhalecc/static-php-cli

Build single static PHP binary, with PHP project together, with popular extensions included.

1.8k13.9k](/packages/crazywhalecc-static-php-cli)[matthiasnoback/symfony-console-form

Use Symfony forms for Console command input

368264.8k8](/packages/matthiasnoback-symfony-console-form)[mahocommerce/maho

Free and open source ecommerce platform, created in 2024 on the M1 platform, PHP 8.3+

1322.1k12](/packages/mahocommerce-maho)[shel/neos-terminal

Neos CMS Ui terminal for running Eel expressions and other commands

1441.3k](/packages/shel-neos-terminal)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
