I am trying to create a artisan command with a --debug option in laravel. To use the debug switch within the whole class scope I use the __construct and assign it to a class property.
public function __construct(){
parent::__construct();
$this->debug = $this->option('debug');
}
there is no problem when I use $this->option('debug') within the handle method. But when I use it in the __construct then I get
Call to a member function getOption() on null {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Call to a member function getOption() on null at /Users/user/Sites/app/vendor/laravel/framework/src/Illuminate/Console/Command.php:310)
I am not sure but it looks like as if the option() is not ready at construct time. Checked the document but could't find anything. Is there any one who knows something about it or a way how I could accomplish that?