Sto solo agli inizi con la OO concetti di base in PHP,
Foo.php
class Foo extends Command {
public function __construct()
{
parent::__construct();
}
public function fire()
{
$bar = new Bar();
}
}
Bar. php
class Bar extends Foo {
public function __construct()
{
parent::__construct();
$this->info('Bar');
}
}
Quando eseguo Foo::fire()
dà: Call to undefined method Foo::__construct()
. Ma lo Foo
ha chiaramente un costruttore, cosa sto facendo male?
Un'altra cosa che sospetto è che potrebbe trattarsi di un problema di Laravel piuttosto che di PHP. Questo è un comando artisan
che ho creato.
EDIT:
chiamando anche $this->info('Bar')
qualsiasi parte Bar
darà anche Call to a member function writeln() on a non-object
. Perché non posso chiamare il metodo di un genitore dalla classe figlio?
Questo è stato un approccio migliore per me: https://stackoverflow.com/a/41122816/470749 E sto anche indagando su https://stackoverflow.com/a/38064494/470749 per vedere se questo è il miglior modo. – Ryan