Search code examples
phplaravellaravel-artisan

How to create an Artisan command which does not throw errors when options passed to it are not defined in its signature?


I want to create a command with options not defined in its signature (I directly pass the options to another command inside mine).

Currently, when I run my command without having its signature precisely defined, it throws an error:

The "--my-option-not-defined-in-signatue" option does not exist. 

Is there a way to disable this check?


Solution

  • In the command constructor, you can disable those checks by using the method ignoreValidationErrors(), like so:

    public function __construct()
    {
        parent::__construct();
    
        $this->ignoreValidationErrors();
    }